Skip to content

Commit dca93f8

Browse files
committed
test: add mock isoString date, match csv contents
1 parent a9c9224 commit dca93f8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/web/src/hooks/__tests__/useInstrumentVisualization.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { act } from '@testing-library/react';
44
import { afterEach, describe, expect, it, vi } from 'vitest';
55

66
import { useInstrumentVisualization } from '../useInstrumentVisualization';
7+
import { toBasicISOString } from '@douglasneuroinformatics/libjs';
78

89
const mockUseInstrument = vi.hoisted(() =>
910
vi.fn(() => ({
@@ -34,6 +35,8 @@ const mockStore = {
3435
}))
3536
};
3637

38+
const mockBasicIsoString = '2025-04-30';
39+
3740
const mockUseDownload = vi.fn();
3841

3942
const mockNotification = {
@@ -79,6 +82,10 @@ vi.mock('@/hooks/useInstrumentRecords', () => ({
7982
useInstrumentRecords: () => mockInstrumentRecords
8083
}));
8184

85+
vi.mock('@douglasneuroinformatics/libjs', () => ({
86+
toBasicISOString: vi.fn(() => mockBasicIsoString)
87+
}));
88+
8289
describe('useInstrumentVisualization tests', () => {
8390
afterEach(() => {
8491
vi.clearAllMocks();
@@ -97,6 +104,7 @@ describe('useInstrumentVisualization tests', () => {
97104
const [filename, getContentFn] = mockUseDownload.mock.calls[0];
98105
expect(filename).toContain('.csv');
99106
const csvContents = getContentFn();
107+
expect(csvContents).toMatch('subjectId,Date,someValue\r\ntestId,2025-04-30,abc');
100108
});
101109
});
102110
});

0 commit comments

Comments
 (0)