From 10d504a34a85b6ca61ad234958a006752350ec4c Mon Sep 17 00:00:00 2001 From: Priyanka Terala Date: Tue, 7 May 2024 11:28:25 +0530 Subject: [PATCH] UIU-3114 - add unit test --- .../ReadingRoomAccess/ReadingRoomAccess.js | 2 -- .../ReadingRoomAccess/ReadingRoomAccess.test.js | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.js b/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.js index b136d4394..900d4b936 100644 --- a/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.js +++ b/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.js @@ -12,8 +12,6 @@ import { MultiColumnList, NoValue, SearchField, - Row, - Column, } from '@folio/stripes/components'; import { ViewMetaData } from '@folio/stripes/smart-components'; diff --git a/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.test.js b/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.test.js index d8e6749c7..d41e406f1 100644 --- a/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.test.js +++ b/src/components/UserDetailSections/ReadingRoomAccess/ReadingRoomAccess.test.js @@ -1,13 +1,10 @@ -import { screen, render, fireEvent } from '@folio/jest-config-stripes/testing-library/react'; +import { screen, render, fireEvent, waitFor } from '@folio/jest-config-stripes/testing-library/react'; import ReadingRoomAccess from './ReadingRoomAccess'; jest.unmock('@folio/stripes/components'); jest.mock('@folio/stripes/components', () => ({ ...jest.requireActual('@folio/stripes/components'), - MultiColumnList: jest.fn((props) => ( -
- )), SearchField: jest.fn((props) => ( { it('should display MultiColumnList', () => { render(); - expect(screen.getByTestId('reading-room-access-mcl')).toBeDefined(); + expect(document.querySelectorAll('[class^="mclContainer"]')).toBeDefined(); }); it('should display search field', () => { @@ -64,10 +61,12 @@ describe('ReadingRoomAccess', () => { expect(screen.getByPlaceholderText('ui-users.readingRoom.filter')).toBeDefined(); }); - it('should filter MCL records "Name" column, based on the string entered in search box', () => { + it('should filter MCL records "Name" column, based on the string entered in search box', async () => { render(); const inputEl = screen.getByPlaceholderText('ui-users.readingRoom.filter'); fireEvent.change(inputEl, { target: { value: '1' } }); - expect(screen.getByTestId('reading-room-access-mcl')).toBeDefined(); + const numOfRows = document.querySelectorAll('[class^="mclRowFormatterContainer"]').length; + console.log('numOfRows ', numOfRows); + await waitFor(() => expect(numOfRows).toBe(1)); }); });