Skip to content

Commit 7f10867

Browse files
authored
test(datetime): getToday unit test (#24830)
1 parent cd05961 commit 7f10867

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

core/src/components/datetime/test/data.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {
22
generateMonths,
33
getDaysOfWeek,
4-
generateTime
4+
generateTime,
5+
getToday
56
} from '../utils/data';
67

78
describe('generateMonths()', () => {
@@ -334,3 +335,22 @@ describe('generateTime()', () => {
334335

335336
})
336337
})
338+
339+
describe('getToday', () => {
340+
341+
beforeAll(() => {
342+
jest.useFakeTimers('modern');
343+
// System time is zero based, 1 = February
344+
jest.setSystemTime(new Date(2022, 1, 21));
345+
});
346+
347+
it('should return today', () => {
348+
const res = getToday();
349+
350+
const expected = new Date();
351+
expected.setHours(expected.getHours() - (expected.getTimezoneOffset() / 60));
352+
353+
expect(res).toEqual('2022-02-21T00:00:00.000Z');
354+
});
355+
356+
});

0 commit comments

Comments
 (0)