Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover with tests PostDirectionChip component #687

Merged
merged 2 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import PostDirectionChip from '../PostDirectionChip';

const handleClickMock = jest.fn();

describe('PostDirectionChip test', () => {
it('should render PostDirectionChip component and match snapshot', () => {
const { asFragment } = render(
<PostDirectionChip
labelName="Офтальмологія"
handleClick={handleClickMock}
/>,
);
expect(asFragment()).toMatchSnapshot();
});
it('should call handleClick function', () => {
render(
<PostDirectionChip
labelName="Офтальмологія"
handleClick={handleClickMock}
/>,
);
const button = screen.getByRole('button');
userEvent.click(button);
expect(handleClickMock).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PostDirectionChip test should render PostDirectionChip component and match snapshot 1`] = `
<DocumentFragment>
<div
class="MuiButtonBase-root MuiChip-root PostDirectionChip-directionChip-1 PostDirectionChip-directionChip-2 MuiChip-sizeSmall MuiChip-clickable"
role="button"
tabindex="0"
>
<span
class="MuiChip-label MuiChip-labelSmall"
>
Офтальмологія
</span>
<span
class="MuiTouchRipple-root"
/>
</div>
</DocumentFragment>
`;