-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.test.js
35 lines (28 loc) · 948 Bytes
/
index.test.js
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
34
35
const index = require('../');
const { NOW } = require('../constants');
test('Date.now() from `setup-jest` to match snapshot w/o options', () => {
expect(Date.now()).toEqual(NOW);
expect(Date.now()).toMatchSnapshot();
});
test('Date.now() to match snapshot w/o options', () => {
index();
expect(Date.now()).toEqual(NOW);
expect(Date.now()).toMatchSnapshot();
});
test('init function returns the used `now` value', () => {
expect(index()).toEqual(NOW);
const now = new Date('2017-06-22');
expect(index(now)).toEqual(now.getTime());
});
test('Date.now() to match snapshot w/ options', () => {
const now = new Date('2017-06-22');
index(now);
expect(Date.now()).toEqual(now.getTime());
expect(Date.now()).toMatchSnapshot();
});
test('Date.now, as a mock function, exposes mockRestore()', () => {
const mocked = Date.now();
Date.now.mockRestore();
const real = Date.now();
expect(real).toBeGreaterThan(mocked);
});