diff --git a/src/old/lib/components/Modals/InformationModal.test.tsx b/src/old/lib/components/Modals/InformationModal.test.tsx new file mode 100644 index 000000000..733648c22 --- /dev/null +++ b/src/old/lib/components/Modals/InformationModal.test.tsx @@ -0,0 +1,86 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { + InformationModal, + IConfirmationModalWithButtonProps, +} from './InformationModal'; + +const PROPS_MOCK: IConfirmationModalWithButtonProps = { + message: 'Test Message', + buttonText: 'Ok', + buttonIcon:
Close Icon
, + loading: true, + disabled: false, +}; + +const renderModal = () => { + render( + , + ); +}; + +describe('InformationModal', () => { + beforeEach(() => renderModal()); + it('render component and match snapshot', () => { + const { asFragment } = render( + , + ); + expect(asFragment()).toMatchSnapshot(); + }); + it('render close button', () => { + expect(screen.getAllByRole('button')[0]).toHaveTextContent('Close Icon'); + }); + it('render Ok button', () => { + expect(screen.getAllByRole('button')[1]).toHaveTextContent('Ok'); + }); +}); + +describe('InformationModal events', () => { + it('should closes when close button is clicked', () => { + const { asFragment } = render( + , + ); + const closeBtn = screen.getByText('Close Icon'); + userEvent.click(closeBtn); + expect(asFragment()).toMatchSnapshot(); + }); + it('should closes when Ok button is clicked', () => { + const { asFragment } = render( + , + ); + const closeBtn = screen.getByText('Ok'); + userEvent.click(closeBtn); + expect(asFragment()).toMatchSnapshot(); + }); +}); + +describe('InformationModal loading status', () => { + it('render with loading icon', () => { + const { asFragment } = render( + , + ); + expect(asFragment()).toMatchSnapshot(); + }); +}); diff --git a/src/old/lib/components/Modals/__snapshots__/InformationModal.test.tsx.snap b/src/old/lib/components/Modals/__snapshots__/InformationModal.test.tsx.snap new file mode 100644 index 000000000..9ac8700d6 --- /dev/null +++ b/src/old/lib/components/Modals/__snapshots__/InformationModal.test.tsx.snap @@ -0,0 +1,201 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`InformationModal events should closes when Ok button is clicked 1`] = ` + +
+ + +
+
+`; + +exports[`InformationModal events should closes when close button is clicked 1`] = ` + +
+ + +
+
+`; + +exports[`InformationModal loading status render with loading icon 1`] = ` + +
+ + +
+
+`; + +exports[`InformationModal render component and match snapshot 1`] = ` + +
+ + +
+
+`;