Skip to content

Commit 680d302

Browse files
authored
Merge pull request #18 from xx45/dev
test(fix test): fix test millisecond
2 parents d63456a + 5ad890e commit 680d302

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"eslint-plugin-import": "^2.10.0",
3535
"eslint-plugin-jest": "^21.15.0",
3636
"jest": "^22.4.3",
37+
"mockdate": "^2.0.2",
3738
"moment": "^2.22.0",
3839
"pre-commit": "^1.2.2",
3940
"rollup": "^0.57.1",

test/display.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import moment from 'moment'
2+
import MockDate from 'mockdate'
23
import dayjs from '../src'
34

5+
beforeEach(() => {
6+
MockDate.set(new Date())
7+
})
8+
9+
afterEach(() => {
10+
MockDate.reset()
11+
})
12+
413
test('Format no formatStr', () => {
514
expect(dayjs().format()).toBe(moment().format())
615
})

test/get-set.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import moment from 'moment'
2+
import MockDate from 'mockdate'
23
import dayjs from '../src'
34

5+
beforeEach(() => {
6+
MockDate.set(new Date())
7+
})
8+
9+
afterEach(() => {
10+
MockDate.reset()
11+
})
12+
413
test('Year', () => {
514
expect(dayjs().year()).toBe(moment().year())
615
})

test/manipulate.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import moment from 'moment'
2+
import MockDate from 'mockdate'
23
import dayjs from '../src'
34

5+
beforeEach(() => {
6+
MockDate.set(new Date())
7+
})
8+
9+
afterEach(() => {
10+
MockDate.reset()
11+
})
12+
413
test('StartOf Year', () => {
514
expect(dayjs().startOf('year').unix()).toBe(moment().startOf('year').unix())
615
})

test/parse.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import moment from 'moment'
2+
import MockDate from 'mockdate'
23
import dayjs from '../src'
34

5+
beforeEach(() => {
6+
MockDate.set(new Date())
7+
})
8+
9+
afterEach(() => {
10+
MockDate.reset()
11+
})
12+
413
test('Now', () => {
514
expect(dayjs().unix()).toBe(moment().unix())
615
})

0 commit comments

Comments
 (0)