From 1593cd4c8e7100053e2342f391cb201691c7a3c2 Mon Sep 17 00:00:00 2001 From: Priyanka Terala Date: Fri, 27 Dec 2024 16:14:48 +0530 Subject: [PATCH] add unit tests for UserSearchModal component from scratch --- src/UserSearchModal.test.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/UserSearchModal.test.js diff --git a/src/UserSearchModal.test.js b/src/UserSearchModal.test.js new file mode 100644 index 0000000..d1b09d8 --- /dev/null +++ b/src/UserSearchModal.test.js @@ -0,0 +1,27 @@ +import { screen, render } from '@folio/jest-config-stripes/testing-library/react'; + +import UserSearchModal from './UserSearchModal'; + +jest.mock('./UserSearchContainer', () => { + return jest.fn(() =>
UserSearchContainer
); +}); + +describe('UserSearchModal', () => { + it('should display search label', () => { + render(); + + expect(screen.getByText('ui-plugin-find-user.searchFieldLabel')).toBeInTheDocument(); + }); + + it('should render "UserSearchContainer"', () => { + expect(screen.getByText('UserSearchContainer')).toBeInTheDocument(); + }); + + it('close modal on clicking close button', () => { + const button = screen.getByRole('button', { name: 'Dismiss modal' }); + expect(button).toBeInTheDocument(); + + button.click(); + expect(screen.getByText('UserSearchContainer')).not.toBeInTheDocument(); + }); +});