2020-10-04 03:57:07 +05:30
|
|
|
import { createFakeDateClass, DEFAULT_ARGS, useRealDate } from './fake_date';
|
|
|
|
|
|
|
|
describe('spec/helpers/fake_date', () => {
|
|
|
|
describe('createFakeDateClass', () => {
|
|
|
|
let FakeDate;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
useRealDate();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
FakeDate = createFakeDateClass(DEFAULT_ARGS);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use default args', () => {
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(new FakeDate()).toMatchInlineSnapshot(`2020-07-06T00:00:00.000Z`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use default args when called as a function', () => {
|
|
|
|
expect(FakeDate()).toMatchInlineSnapshot(
|
|
|
|
`"Mon Jul 06 2020 00:00:00 GMT+0000 (Greenwich Mean Time)"`,
|
|
|
|
);
|
2020-10-04 03:57:07 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should have deterministic now()', () => {
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(FakeDate.now()).toMatchInlineSnapshot(`1593993600000`);
|
2020-10-04 03:57:07 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should be instanceof Date', () => {
|
|
|
|
expect(new FakeDate()).toBeInstanceOf(Date);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be instanceof self', () => {
|
|
|
|
expect(new FakeDate()).toBeInstanceOf(FakeDate);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|