File tree Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 34
34
"eslint-plugin-import" : " ^2.10.0" ,
35
35
"eslint-plugin-jest" : " ^21.15.0" ,
36
36
"jest" : " ^22.4.3" ,
37
+ "mockdate" : " ^2.0.2" ,
37
38
"moment" : " ^2.22.0" ,
38
39
"pre-commit" : " ^1.2.2" ,
39
40
"rollup" : " ^0.57.1" ,
Original file line number Diff line number Diff line change 1
1
import moment from 'moment'
2
+ import MockDate from 'mockdate'
2
3
import dayjs from '../src'
3
4
5
+ beforeEach ( ( ) => {
6
+ MockDate . set ( new Date ( ) )
7
+ } )
8
+
9
+ afterEach ( ( ) => {
10
+ MockDate . reset ( )
11
+ } )
12
+
4
13
test ( 'Format no formatStr' , ( ) => {
5
14
expect ( dayjs ( ) . format ( ) ) . toBe ( moment ( ) . format ( ) )
6
15
} )
Original file line number Diff line number Diff line change 1
1
import moment from 'moment'
2
+ import MockDate from 'mockdate'
2
3
import dayjs from '../src'
3
4
5
+ beforeEach ( ( ) => {
6
+ MockDate . set ( new Date ( ) )
7
+ } )
8
+
9
+ afterEach ( ( ) => {
10
+ MockDate . reset ( )
11
+ } )
12
+
4
13
test ( 'Year' , ( ) => {
5
14
expect ( dayjs ( ) . year ( ) ) . toBe ( moment ( ) . year ( ) )
6
15
} )
Original file line number Diff line number Diff line change 1
1
import moment from 'moment'
2
+ import MockDate from 'mockdate'
2
3
import dayjs from '../src'
3
4
5
+ beforeEach ( ( ) => {
6
+ MockDate . set ( new Date ( ) )
7
+ } )
8
+
9
+ afterEach ( ( ) => {
10
+ MockDate . reset ( )
11
+ } )
12
+
4
13
test ( 'StartOf Year' , ( ) => {
5
14
expect ( dayjs ( ) . startOf ( 'year' ) . unix ( ) ) . toBe ( moment ( ) . startOf ( 'year' ) . unix ( ) )
6
15
} )
Original file line number Diff line number Diff line change 1
1
import moment from 'moment'
2
+ import MockDate from 'mockdate'
2
3
import dayjs from '../src'
3
4
5
+ beforeEach ( ( ) => {
6
+ MockDate . set ( new Date ( ) )
7
+ } )
8
+
9
+ afterEach ( ( ) => {
10
+ MockDate . reset ( )
11
+ } )
12
+
4
13
test ( 'Now' , ( ) => {
5
14
expect ( dayjs ( ) . unix ( ) ) . toBe ( moment ( ) . unix ( ) )
6
15
} )
You can’t perform that action at this time.
0 commit comments