Skip to content

Commit

Permalink
UIU-3112 - add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed May 15, 2024
1 parent 621185c commit e1e9eaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ReadingRoomAccess = (props) => {
if (!isPending) {
setSortedRecordsDetails(prev => ({
...prev.sortedRecordsDetails,
data: orderBy(userRRAPermissions, ['access'])
data: orderBy(userRRAPermissions, [rraColumns.ACCESS])
}));
}
}, [userRRAPermissions, isPending]);
Expand All @@ -61,7 +61,7 @@ const ReadingRoomAccess = (props) => {
const filteredRRs = userRRAPermissions.filter(r => r.readingRoomName.includes(name));
setSortedRecordsDetails(prev => ({
...prev.sortedRecordsDetails,
data: orderBy(filteredRRs, ['access'])
data: orderBy(filteredRRs, [rraColumns.ACCESS])
}));
};

Expand Down Expand Up @@ -125,7 +125,7 @@ const ReadingRoomAccess = (props) => {
onChange={filterReadingRoomsByName}
onClear={() => setSortedRecordsDetails(prev => ({
...prev.sortedRecordsDetails,
data: orderBy(userRRAPermissions, ['access'])
data: orderBy(userRRAPermissions, [rraColumns.ACCESS])
}))}
placeholder={intl.formatMessage({ id:'ui-users.readingRoom.filter' })}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ describe('ReadingRoomAccess', () => {
await waitFor(() => expect(numOfRows).toBe(1));
});

it('should render all records when search string is cleared', async () => {
render(<ReadingRoomAccess {...alteredProps} />);
const inputEl = screen.getByPlaceholderText('ui-users.readingRoom.filter');
fireEvent.change(inputEl, { target: { value: 'room 1' } });
const numOfRows = document.querySelectorAll('[class^="mclRowFormatterContainer"]').length;
await waitFor(() => expect(numOfRows).toBe(1));
fireEvent.change(inputEl, { target: { value: '' } });
expect(document.querySelectorAll('[class^="mclRowFormatterContainer"]').length).toBe(2);
});

it('should render updated date', () => {
render(<ReadingRoomAccess {...alteredProps} />);
expect(screen.getByText('ui-users.readingRoom.metaSection.lastUpdatedDetails')).toBeDefined();
Expand Down

0 comments on commit e1e9eaa

Please sign in to comment.