Skip to content

Commit a245fe5

Browse files
committed
test: use toBasicISOString method to compare dates of output
1 parent 057d54c commit a245fe5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, it, expect, vi, beforeEach } from 'vitest';
22
import { renderHook, act } from '@testing-library/react';
33
import { useInstrumentVisualization } from '../useInstrumentVisualization';
4+
import { toBasicISOString } from '@douglasneuroinformatics/libjs';
45

56
const mockUseInstrument = vi.hoisted(() =>
67
vi.fn(() => ({
@@ -56,10 +57,6 @@ vi.mock('@/hooks/useInstrumentRecords', () => ({
5657
useInstrumentRecords: () => mockInstrumentRecords
5758
}));
5859

59-
vi.mock('@douglasneuroinformatics/libjs', () => ({
60-
toBasicISOString: vi.fn(() => mockBasicIsoString)
61-
}));
62-
6360
describe('useInstrumentVisualization', () => {
6461
beforeEach(() => {
6562
vi.clearAllMocks();
@@ -76,7 +73,7 @@ describe('useInstrumentVisualization', () => {
7673
const [filename, getContentFn] = mockDownloadFn.mock.calls[0];
7774
expect(filename).toContain('.csv');
7875
const csvContents = getContentFn();
79-
expect(csvContents).toMatch('subjectId,Date,someValue\r\ntestId,2025-04-30,abc');
76+
expect(csvContents).toMatch(`subjectId,Date,someValue\r\ntestId,${toBasicISOString(new Date())},abc`);
8077
});
8178
});
8279
describe('TSV', () => {
@@ -90,7 +87,7 @@ describe('useInstrumentVisualization', () => {
9087
const [filename, getContentFn] = mockDownloadFn.mock.calls[0];
9188
expect(filename).toContain('.tsv');
9289
const tsvContents = getContentFn();
93-
expect(tsvContents).toMatch('subjectId\tDate\tsomeValue\r\ntestId\t2025-04-30\tabc');
90+
expect(tsvContents).toMatch(`subjectId\tDate\tsomeValue\r\ntestId\t${toBasicISOString(new Date())}\tabc`);
9491
});
9592
});
9693
describe('CSV Long', () => {
@@ -104,7 +101,9 @@ describe('useInstrumentVisualization', () => {
104101
const [filename, getContentFn] = mockDownloadFn.mock.calls[0];
105102
expect(filename).toContain('.csv');
106103
const csvLongContents = getContentFn();
107-
expect(csvLongContents).toMatch('Date,SubjectID,Value,Variable\r\n2025-04-30,testId,abc,someValue');
104+
expect(csvLongContents).toMatch(
105+
`Date,SubjectID,Value,Variable\r\n${toBasicISOString(new Date())},testId,abc,someValue`
106+
);
108107
});
109108
});
110109
describe('TSV Long', () => {
@@ -118,7 +117,9 @@ describe('useInstrumentVisualization', () => {
118117
const [filename, getContentFn] = mockDownloadFn.mock.calls[0];
119118
expect(filename).toMatch('.tsv');
120119
const tsvLongContents = getContentFn();
121-
expect(tsvLongContents).toMatch('Date\tSubjectID\tValue\tVariable\r\n2025-04-30\ttestId\tabc\tsomeValue');
120+
expect(tsvLongContents).toMatch(
121+
`Date\tSubjectID\tValue\tVariable\r\n${toBasicISOString(new Date())}\ttestId\tabc\tsomeValue`
122+
);
122123
});
123124
});
124125
describe('JSON', () => {

0 commit comments

Comments
 (0)