Skip to content

Commit

Permalink
UIU-3114 - add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed May 7, 2024
1 parent a1906a6 commit 10d504a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
MultiColumnList,
NoValue,
SearchField,
Row,
Column,
} from '@folio/stripes/components';
import { ViewMetaData } from '@folio/stripes/smart-components';

Expand Down
Original file line number Diff line number Diff line change
@@ -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) => (
<div data-testid={props['data-testid']} />
)),
SearchField: jest.fn((props) => (
<input
{...props}
Expand Down Expand Up @@ -56,18 +53,20 @@ describe('ReadingRoomAccess', () => {

it('should display MultiColumnList', () => {
render(<ReadingRoomAccess {...alteredProps} />);
expect(screen.getByTestId('reading-room-access-mcl')).toBeDefined();
expect(document.querySelectorAll('[class^="mclContainer"]')).toBeDefined();
});

it('should display search field', () => {
render(<ReadingRoomAccess {...alteredProps} />);
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(<ReadingRoomAccess {...alteredProps} />);
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));
});
});

0 comments on commit 10d504a

Please sign in to comment.