forked from iamkun/dayjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharraySupport.test.js
executable file
·52 lines (45 loc) · 1.01 KB
/
arraySupport.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import MockDate from 'mockdate'
import moment from 'moment'
import dayjs from '../../src'
import arraySupport from '../../src/plugin/arraySupport'
import utc from '../../src/plugin/utc'
dayjs.extend(utc)
dayjs.extend(arraySupport)
beforeEach(() => {
MockDate.set(new Date())
})
afterEach(() => {
MockDate.reset()
})
describe('parse empty array', () => {
it('local', () => {
expect(dayjs([]).format())
.toBe(moment([]).format())
})
it('utc', () => {
expect(dayjs.utc([]).format())
.toBe(moment.utc([]).format())
})
})
const testArrs = [
[2010, 1, 14, 15, 25, 50, 125],
[2010],
[2010, 6],
[2010, 6, 10]
]
describe('parse array local', () => {
testArrs.forEach((testArr) => {
it(testArr, () => {
expect(dayjs(testArr).format())
.toBe(moment(testArr).format())
})
})
})
describe('parse array utc', () => {
testArrs.forEach((testArr) => {
it(testArr, () => {
expect(dayjs.utc(testArr).format())
.toBe(moment.utc(testArr).format())
})
})
})