From b137ae5c67c4d2071c169c8b2eccf1a6f134d4e6 Mon Sep 17 00:00:00 2001 From: Dmitriy-Litvinenko Date: Thu, 20 Jun 2024 18:03:11 +0300 Subject: [PATCH] UIREQMED-3: Add Search field for Mediated requests activity page --- .../MediatedRequestsFilters.test.js | 4 ---- .../MediatedRequestLevelFilter.js | 2 +- .../MediatedRequestStatusFilter.js | 2 +- .../NavigationMenu/NavigationMenu.js | 4 ++-- src/utils.js | 2 +- src/utils.test.js | 19 +++++++++++++++++++ 6 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 src/utils.test.js diff --git a/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/MediatedRequestsFilters.test.js b/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/MediatedRequestsFilters.test.js index 581c7a7..b0e04e9 100644 --- a/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/MediatedRequestsFilters.test.js +++ b/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/MediatedRequestsFilters.test.js @@ -4,14 +4,10 @@ import { } from '@folio/jest-config-stripes/testing-library/react'; import MediatedRequestsFilters from './MediatedRequestsFilters'; - import { - MediatedRequestLevelFilter, MediatedRequestStatusFilter, Search, } from './components'; -import NavigationMenu from '../../../NavigationMenu'; -import { getMediatedRequestsActivitiesUrl } from '../../../../constants'; jest.mock('./components', () => ({ MediatedRequestLevelFilter: jest.fn((props) => (
)), diff --git a/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestLevelFilter/MediatedRequestLevelFilter.js b/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestLevelFilter/MediatedRequestLevelFilter.js index 8f19600..588ce3b 100644 --- a/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestLevelFilter/MediatedRequestLevelFilter.js +++ b/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestLevelFilter/MediatedRequestLevelFilter.js @@ -35,7 +35,7 @@ const MediatedRequestLevelFilter = () => { > {}} /> diff --git a/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestStatusFilter/MediatedRequestStatusFilter.js b/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestStatusFilter/MediatedRequestStatusFilter.js index 0b85950..c6740c6 100644 --- a/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestStatusFilter/MediatedRequestStatusFilter.js +++ b/src/components/MediatedRequestsActivities/components/MediatedRequestsFilters/components/MediatedRequestStatusFilter/MediatedRequestStatusFilter.js @@ -35,7 +35,7 @@ const MediatedRequestStatusFilter = () => { > {}} /> diff --git a/src/components/NavigationMenu/NavigationMenu.js b/src/components/NavigationMenu/NavigationMenu.js index 57d9a77..c326847 100644 --- a/src/components/NavigationMenu/NavigationMenu.js +++ b/src/components/NavigationMenu/NavigationMenu.js @@ -13,6 +13,8 @@ import { getSendItemInTransitUrl, } from '../../constants'; +import styles from './NavigationMenu.css'; + export const getDataOptions = (intl) => ([ { label: intl.formatMessage({ id: 'ui-requests-mediated.app.mediatedRequestsActivities.navigation' }), @@ -44,8 +46,6 @@ export const handleChangeMenu = (event, location, history) => { history.push(destination); }; -import styles from './NavigationMenu.css'; - const NavigationMenu = ({ value, separator, diff --git a/src/utils.js b/src/utils.js index b127da5..1925274 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,4 +1,4 @@ -export const transformRequestFilterOptions = (source = [], formatMessage) => ( +export const transformRequestFilterOptions = (formatMessage, source = []) => ( source.map(({ label, value }) => ({ label: formatMessage({ id: label }), value, diff --git a/src/utils.test.js b/src/utils.test.js new file mode 100644 index 0000000..b356eb6 --- /dev/null +++ b/src/utils.test.js @@ -0,0 +1,19 @@ +import { + transformRequestFilterOptions, +} from './utils'; + +describe('transformRequestFilterOptions', () => { + const formatMessage = jest.fn(({ id }) => id); + const option = { + label: 'label', + value: 'value', + }; + + it('should return data options', () => { + expect(transformRequestFilterOptions(formatMessage, [option])).toEqual([option]); + }); + + it('should not return data options', () => { + expect(transformRequestFilterOptions(formatMessage)).toEqual([]); + }); +});