@@ -9,12 +9,19 @@ import useDerivedDataRecencyEndpoints from '@app/pages/clinicworkspace/TideDashb
99const mockStore = configureStore ( [ thunk ] ) ;
1010
1111describe ( 'useDerivedDataRecencyEndpoints' , ( ) => {
12- let store ;
12+ const renderEndpointsHook = ( tideDashboardFilters = { } ) => {
13+ const store = mockStore ( {
14+ blip : {
15+ timePrefs : { timezoneAware : false , timezoneName : null } ,
16+ tideDashboardFilters : tideDashboardFilters ,
17+ } ,
18+ } ) ;
1319
14- const renderEndpointsHook = ( filters ) => renderHook (
15- ( ) => useDerivedDataRecencyEndpoints ( filters ) ,
16- { wrapper : ( { children } ) => < Provider store = { store } > { children } </ Provider > }
17- ) . result . current ;
20+ return renderHook (
21+ ( ) => useDerivedDataRecencyEndpoints ( ) ,
22+ { wrapper : ( { children } ) => < Provider store = { store } > { children } </ Provider > }
23+ ) . result . current ;
24+ } ;
1825
1926 beforeEach ( ( ) => {
2027 // Fake only Date so "now" is pinned; the localized ceiling of now is 2025-05-30T00:00:00.000Z
@@ -29,8 +36,6 @@ describe('useDerivedDataRecencyEndpoints', () => {
2936 'setTimeout' , 'clearTimeout' ,
3037 ] ,
3138 } ) ;
32-
33- store = mockStore ( { blip : { timePrefs : { timezoneAware : false , timezoneName : null } } } ) ;
3439 } ) ;
3540
3641 afterEach ( ( ) => {
@@ -44,38 +49,31 @@ describe('useDerivedDataRecencyEndpoints', () => {
4449 ] ) ;
4550 } ) ;
4651
47- it ( 'derives the window for the "Within 2 days" option' , ( ) => {
52+ it ( 'derives the window when the "Within 2 days" option' , ( ) => {
4853 expect ( renderEndpointsHook ( { lastData : 2 } ) ) . toStrictEqual ( [
4954 '2025-05-28T00:00:00.000Z' , // lastDataFrom
5055 '2025-05-30T00:00:00.000Z' , // lastDataTo
5156 ] ) ;
5257 } ) ;
5358
54- it ( 'derives the window for the "Within 7 days" option' , ( ) => {
59+ it ( 'derives the window when the "Within 7 days" option' , ( ) => {
5560 expect ( renderEndpointsHook ( { lastData : 7 } ) ) . toStrictEqual ( [
5661 '2025-05-23T00:00:00.000Z' , // lastDataFrom
5762 '2025-05-30T00:00:00.000Z' , // lastDataTo
5863 ] ) ;
5964 } ) ;
6065
61- it ( 'derives the window for the "Within 14 days" option' , ( ) => {
66+ it ( 'derives the window when the "Within 14 days" option' , ( ) => {
6267 expect ( renderEndpointsHook ( { lastData : 14 } ) ) . toStrictEqual ( [
6368 '2025-05-16T00:00:00.000Z' , // lastDataFrom
6469 '2025-05-30T00:00:00.000Z' , // lastDataTo
6570 ] ) ;
6671 } ) ;
6772
68- it ( 'derives the window for the "Within 30 days" option' , ( ) => {
73+ it ( 'derives the window when the "Within 30 days" option' , ( ) => {
6974 expect ( renderEndpointsHook ( { lastData : 30 } ) ) . toStrictEqual ( [
7075 '2025-04-30T00:00:00.000Z' , // lastDataFrom
7176 '2025-05-30T00:00:00.000Z' , // lastDataTo
7277 ] ) ;
7378 } ) ;
74-
75- it ( 'defaults to the 7-day tide dashboard window when called without filters' , ( ) => {
76- expect ( renderEndpointsHook ( ) ) . toStrictEqual ( [
77- '2025-05-23T00:00:00.000Z' , // lastDataFrom
78- '2025-05-30T00:00:00.000Z' , // lastDataTo
79- ] ) ;
80- } ) ;
8179} ) ;
0 commit comments