@@ -12,11 +12,50 @@ describe('Datepicker shallowMounted', () => {
12
12
wrapper . destroy ( )
13
13
} )
14
14
15
- it ( "shows today's date if no open date is set" , ( ) => {
15
+ it ( "defaults to today's date if no open date is set" , ( ) => {
16
16
const today = new Date ( )
17
17
expect ( wrapper . vm . pageDate . getMonth ( ) ) . toEqual ( today . getMonth ( ) )
18
18
expect ( wrapper . vm . pageDate . getFullYear ( ) ) . toEqual ( today . getFullYear ( ) )
19
19
} )
20
+
21
+ it ( "defaults to today's date when invalid" , async ( ) => {
22
+ const today = new Date ( )
23
+
24
+ await wrapper . setProps ( {
25
+ openDate : 'invalid' ,
26
+ } )
27
+
28
+ expect ( wrapper . vm . pageDate . getMonth ( ) ) . toEqual ( today . getMonth ( ) )
29
+ expect ( wrapper . vm . pageDate . getFullYear ( ) ) . toEqual ( today . getFullYear ( ) )
30
+ } )
31
+
32
+ it ( 'accepts an instance of a date object' , async ( ) => {
33
+ await wrapper . setProps ( {
34
+ openDate : new Date ( 2016 , 9 , 12 ) ,
35
+ } )
36
+
37
+ expect ( wrapper . vm . pageDate . getMonth ( ) ) . toEqual ( 9 )
38
+ expect ( wrapper . vm . pageDate . getFullYear ( ) ) . toEqual ( 2016 )
39
+ } )
40
+
41
+ it ( 'accepts a string value' , async ( ) => {
42
+ await wrapper . setProps ( {
43
+ openDate : '2016-10-12' ,
44
+ useUtc : true ,
45
+ } )
46
+
47
+ expect ( wrapper . vm . pageDate . getMonth ( ) ) . toEqual ( 9 )
48
+ expect ( wrapper . vm . pageDate . getFullYear ( ) ) . toEqual ( 2016 )
49
+ } )
50
+
51
+ it ( 'accepts a timestamp value' , async ( ) => {
52
+ await wrapper . setProps ( {
53
+ openDate : new Date ( 2016 , 9 , 12 ) . valueOf ( ) ,
54
+ } )
55
+
56
+ expect ( wrapper . vm . pageDate . getMonth ( ) ) . toEqual ( 9 )
57
+ expect ( wrapper . vm . pageDate . getFullYear ( ) ) . toEqual ( 2016 )
58
+ } )
20
59
} )
21
60
22
61
describe ( 'Datepicker shallowMounted with open date' , ( ) => {
@@ -35,11 +74,6 @@ describe('Datepicker shallowMounted with open date', () => {
35
74
wrapper . destroy ( )
36
75
} )
37
76
38
- it ( 'accepts an instance of a date object' , ( ) => {
39
- expect ( wrapper . vm . pageDate . getMonth ( ) ) . toEqual ( 9 )
40
- expect ( wrapper . vm . pageDate . getFullYear ( ) ) . toEqual ( 2016 )
41
- } )
42
-
43
77
it ( "sets pageTimestamp to be first day of open date's month" , ( ) => {
44
78
const date = new Date ( wrapper . vm . pageTimestamp )
45
79
expect ( wrapper . vm . openDate . valueOf ( ) ) . toEqual ( openDate . valueOf ( ) )
0 commit comments