From 1983bfa03da1671f57bd3836894313195daaf534 Mon Sep 17 00:00:00 2001 From: Priyanka Terala Date: Tue, 10 Dec 2024 17:53:00 +0530 Subject: [PATCH] refine and fix tests --- .../RequestsFilters/RequestsFilters.test.js | 15 ++++++++++++++- .../RetrievalServicePointFilter.js | 2 +- .../RetrievalServicePointFilter.test.js | 11 ++++++++++- src/hooks/index.js | 1 + src/hooks/useRetrievalServicePoints/index.js | 1 + 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/hooks/index.js create mode 100644 src/hooks/useRetrievalServicePoints/index.js diff --git a/src/components/RequestsFilters/RequestsFilters.test.js b/src/components/RequestsFilters/RequestsFilters.test.js index 7ed44614..a2d8c49b 100644 --- a/src/components/RequestsFilters/RequestsFilters.test.js +++ b/src/components/RequestsFilters/RequestsFilters.test.js @@ -27,9 +27,21 @@ jest.mock('./RequestLevelFilter', () => ({ jest.mock('./PickupServicePointFilter', () => ({ PickupServicePointFilter: jest.fn((props) => (
)), })); +jest.mock('./RetrievalServicePointFilter', () => ({ + RetrievalServicePointFilter: jest.fn((props) => (
)), +})); jest.mock('../../hooks', () => ({ ...jest.requireActual('../../hooks'), - useRetrievalServicePoints: jest.fn(), + useRetrievalServicePoints: jest.fn().mockReturnValue([ + { + value: '3a40852d-49fd-4df2-a1f9-6e2641a6e91f', + label: 'Circ desk 1', + }, + { + value: '9d1b77e8-f02e-4b7f-b296-3f2042ddac54', + label: 'Circ desk 2', + }, + ]), })); jest.mock('@folio/stripes/smart-components', () => ({ CheckboxFilter: jest.fn((props) => (
)), @@ -43,6 +55,7 @@ const props = { requestStatus: ['Open'], requestType: ['Hold'], pickupServicePoints: ['1'], + retrievalServicePoints: ['1', '2'], tags: ['Urgent'], requestLevels: [], printStatus: ['Printed'], diff --git a/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.js b/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.js index b4173abc..8d98a30e 100644 --- a/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.js +++ b/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.js @@ -15,7 +15,7 @@ import { requestFilterTypes, } from '../../../constants'; -import useRetrievalServicePoints from '../../../hooks/useRetrievalServicePoints/useRetrievalServicePoints'; +import { useRetrievalServicePoints } from '../../../hooks'; const RetrievalServicePointFilter = ({ activeValues, diff --git a/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.test.js b/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.test.js index 9319790b..6645e18f 100644 --- a/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.test.js +++ b/src/components/RequestsFilters/RetrievalServicePointFilter/RetrievalServicePointFilter.test.js @@ -14,7 +14,16 @@ import { requestFilterTypes } from '../../../constants'; jest.mock('../../../hooks', () => ({ ...jest.requireActual('../../../hooks'), - useRetrievalServicePoints: jest.fn(), + useRetrievalServicePoints: jest.fn().mockReturnValue([ + { + value: '3a40852d-49fd-4df2-a1f9-6e2641a6e91f', + label: 'Circ desk 1', + }, + { + value: '9d1b77e8-f02e-4b7f-b296-3f2042ddac54', + label: 'Circ desk 2', + }, + ]), })); const activeValues = ['test', 'test2']; diff --git a/src/hooks/index.js b/src/hooks/index.js new file mode 100644 index 00000000..7df9cbd4 --- /dev/null +++ b/src/hooks/index.js @@ -0,0 +1 @@ +export { useRetrievalServicePoints } from './useRetrievalServicePoints'; diff --git a/src/hooks/useRetrievalServicePoints/index.js b/src/hooks/useRetrievalServicePoints/index.js new file mode 100644 index 00000000..7532d2aa --- /dev/null +++ b/src/hooks/useRetrievalServicePoints/index.js @@ -0,0 +1 @@ +export { default as useRetrievalServicePoints } from './useRetrievalServicePoints';