Skip to content

Commit

Permalink
test(datetime): getToday unit test (#24830)
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-perkins authored Feb 22, 2022
1 parent cd05961 commit 7f10867
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion core/src/components/datetime/test/data.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
generateMonths,
getDaysOfWeek,
generateTime
generateTime,
getToday
} from '../utils/data';

describe('generateMonths()', () => {
Expand Down Expand Up @@ -334,3 +335,22 @@ describe('generateTime()', () => {

})
})

describe('getToday', () => {

beforeAll(() => {
jest.useFakeTimers('modern');
// System time is zero based, 1 = February
jest.setSystemTime(new Date(2022, 1, 21));
});

it('should return today', () => {
const res = getToday();

const expected = new Date();
expected.setHours(expected.getHours() - (expected.getTimezoneOffset() / 60));

expect(res).toEqual('2022-02-21T00:00:00.000Z');
});

});

0 comments on commit 7f10867

Please sign in to comment.