Skip to content

Commit

Permalink
UIU-3096 - i18zed search field placeholder, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed Apr 3, 2024
1 parent c28a538 commit 1a61706
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, useIntl } from 'react-intl';
// import { Link } from 'react-router-dom';
// import { get } from 'lodash';

Expand Down Expand Up @@ -47,6 +47,7 @@ const mockedRRAData = [
}
];
const ReadingRoomAccess = (props) => {
const intl = useIntl();
const [filteredRRA, setFilteredRRA] = useState(mockedRRAData);
const {
accordionId,
Expand Down Expand Up @@ -126,7 +127,7 @@ const ReadingRoomAccess = (props) => {
<SearchField
onChange={filterReadingRoomsByName}
onClear={() => setFilteredRRA(mockedRRAData)}
placeholder="Search by Reading Room"
placeholder={intl.formatMessage({ id:'ui-users.readingRoom.filter' })}
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ jest.mock('@folio/stripes/components', () => ({
MultiColumnList: jest.fn((props) => (
<div data-testid={props['data-testid']} />
)),
SearchField: jest.fn((props) => (
<input
{...props}
/>
)),
}));

const props = {
Expand All @@ -18,18 +23,23 @@ const props = {
};

describe('ReadingRoomAccess', () => {
const alteredProps = {
...props,
expanded : true,
};

it('should render and accordion', () => {
render(<ReadingRoomAccess {...props} />);
expect(screen.getByText('ui-users.readingRoom.readingRoomAccess')).toBeDefined();
});

it('should display MultiColumnList', () => {
const alteredProps = {
...props,
expanded : true,
};

render(<ReadingRoomAccess {...alteredProps} />);
expect(screen.getByTestId('reading-room-access-mcl')).toBeDefined();
});

it('should display search field', () => {
render(<ReadingRoomAccess {...alteredProps} />);
expect(screen.getByPlaceholderText('ui-users.readingRoom.filter')).toBeDefined();
});
});
1 change: 1 addition & 0 deletions translations/ui-users/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@
"readingRoom.name": "Name",
"readingRoom.note": "Note",
"readingRoom.lastUpdated": "Last updated",
"readingRoom.filter": "Filter",

"crud.closeNewUserDialog": "Close New User Dialog",
"crud.editUser": "Edit User",
Expand Down

0 comments on commit 1a61706

Please sign in to comment.