Skip to content

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciechmarek committed Nov 2, 2023
1 parent bcc7d9c commit 63bde0f
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions src/components/molecules/modal/TitleBar/title-bar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
describe('IconButton', () => {
import { act, configure, render } from '@testing-library/react';
import { ModalTitleBarProps } from './title-bar.interface';
import { UseFormReturn, useForm } from 'react-hook-form';
import { ModalTitleBar } from './title-bar';
import '@testing-library/jest-dom';
import userEvent from '@testing-library/user-event';

describe('TitleBar', () => {
let modalTitleBarProps: ModalTitleBarProps;

beforeEach(() => {
configure({ throwSuggestions: true });

modalTitleBarProps = {
title: 'title',
handleCloseClick: jest.fn(),
};
});

it('should render', () => {
expect(true).toBeTruthy();
const { baseElement } = render(<ModalTitleBar {...modalTitleBarProps} />);
expect(baseElement).toBeTruthy();
});

describe('when the button is clicked', () => {});
describe('when the title bar is rendered', () => {
it('should have the correct title', () => {
const { getByText } = render(<ModalTitleBar {...modalTitleBarProps} />);
const title = getByText('title');
expect(title).toBeTruthy();
});

it('should render the close button', () => {
const { getByRole } = render(<ModalTitleBar {...modalTitleBarProps} />);
const button = getByRole('button');
expect(button).toBeTruthy();
});
});

describe('when the close button is clicked', () => {
it('should call the handleCloseClick function', () => {
const { getByRole } = render(<ModalTitleBar {...modalTitleBarProps} />);
const button = getByRole('button');
button.click();
expect(modalTitleBarProps.handleCloseClick).toHaveBeenCalled();
});
});
});

0 comments on commit 63bde0f

Please sign in to comment.