Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fake_date_spec.js « fake_date « __helpers__ « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 730765e52d29406625cde7b90ba670cb2b0d9ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { createFakeDateClass } from './fake_date';

describe('spec/helpers/fake_date', () => {
  describe('createFakeDateClass', () => {
    let FakeDate;

    beforeEach(() => {
      FakeDate = createFakeDateClass();
    });

    it('should use default args', () => {
      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)"`,
      );
    });

    it('should have deterministic now()', () => {
      expect(FakeDate.now()).toMatchInlineSnapshot(`1593993600000`);
    });

    it('should be instanceof Date', () => {
      expect(new FakeDate()).toBeInstanceOf(Date);
    });

    it('should be instanceof self', () => {
      expect(new FakeDate()).toBeInstanceOf(FakeDate);
    });
  });
});