@@ -139,13 +139,13 @@ describe('datepicker', () => {
139139 expect ( td1 . at ( 14 ) . classes ( ) ) . toContain ( 'actived' )
140140 expect ( td2 . at ( 13 ) . classes ( ) ) . toContain ( 'disabled' )
141141 expect ( td2 . at ( 14 ) . classes ( ) ) . not . toContain ( 'disabled' )
142-
143- const date1 = new Date ( td1 . at ( 14 ) . element . title ) . setHours ( 0 , 0 , 0 , 0 )
142+ const el1 = td1 . at ( 14 ) . element
143+ const date1 = new Date ( + el1 . dataset . year , + el1 . dataset . month , + el1 . textContent )
144144 td2 . at ( 16 ) . trigger ( 'click' )
145145 Vue . nextTick ( ( ) => {
146146 const emitted = wrapper . emitted ( )
147- const date2 = new Date ( td2 . at ( 16 ) . element . title ) . setHours ( 0 , 0 , 0 , 0 )
148-
147+ const el2 = td2 . at ( 16 ) . element
148+ const date2 = new Date ( + el2 . dataset . year , + el2 . dataset . month , + el2 . textContent )
149149 expect ( td2 . at ( 16 ) . classes ( ) ) . toContain ( 'actived' )
150150 expect ( td1 . at ( 15 ) . classes ( ) ) . toContain ( 'inrange' )
151151 expect ( td1 . at ( 16 ) . classes ( ) ) . toContain ( 'inrange' )
@@ -161,7 +161,7 @@ describe('datepicker', () => {
161161 wrapper = shallowMount ( DatePicker , {
162162 propsData : {
163163 range : true ,
164- value : [ new Date ( ' 2018-06-01' ) , new Date ( ' 2018-06-10' ) ] ,
164+ value : [ new Date ( 2018 , 5 , 1 ) , new Date ( 2018 , 5 , 10 ) ] ,
165165 rangeSeparator : '至'
166166 }
167167 } )
@@ -360,21 +360,18 @@ describe('datepicker', () => {
360360 it ( 'prop: dateFormat' , ( ) => {
361361 wrapper = mount ( DatePicker , {
362362 propsData : {
363- value : new Date ( ' 2018-08-08' ) ,
363+ value : new Date ( 2018 , 7 , 8 ) ,
364364 format : '[on] MM-DD-YYYY [at] HH:mm' ,
365365 type : 'datetime'
366366 }
367367 } )
368368 let ss = '08-08-2018'
369- const cell = wrapper . find ( '.mx-panel-date .actived' )
370369 const timeHeader = wrapper . find ( '.mx-time-header' )
371- expect ( cell . element . title ) . toBe ( ss )
372370 expect ( timeHeader . text ( ) ) . toBe ( ss )
373371 wrapper . setProps ( {
374372 dateFormat : 'YYYY-MM-DD'
375373 } )
376374 ss = '2018-08-08'
377- expect ( cell . element . title ) . toBe ( ss )
378375 expect ( timeHeader . text ( ) ) . toBe ( ss )
379376 } )
380377} )
@@ -384,7 +381,7 @@ describe('calendar-panel', () => {
384381 wrapper = mount ( CalendarPanel , {
385382 propsData : {
386383 value : null ,
387- defaultValue : ' 2018-10-01'
384+ defaultValue : new Date ( 2018 , 9 , 1 )
388385 }
389386 } )
390387 const vm = wrapper . vm
@@ -500,7 +497,7 @@ describe('calendar-panel', () => {
500497 } )
501498
502499 it ( 'prop: disabledDays(Array)' , ( ) => {
503- const disabledDays = [ ' 2018-05-01' , new Date ( 2018 , 4 , 3 ) ]
500+ const disabledDays = [ new Date ( 2018 , 4 , 1 ) , new Date ( 2018 , 4 , 3 ) ]
504501 wrapper = mount ( CalendarPanel , {
505502 propsData : {
506503 value : new Date ( 2018 , 4 , 2 ) ,
@@ -510,9 +507,10 @@ describe('calendar-panel', () => {
510507 const tds = wrapper . findAll ( '.mx-panel-date td.disabled' )
511508 expect ( tds . length ) . toBe ( disabledDays . length )
512509 for ( let i = 0 , len = tds . length ; i < len ; i ++ ) {
513- const tdDate = new Date ( tds . at ( i ) . element . title ) . setHours ( 0 , 0 , 0 , 0 )
514- const expectDate = new Date ( disabledDays [ i ] ) . setHours ( 0 , 0 , 0 , 0 )
515- expect ( tdDate ) . toBe ( expectDate )
510+ const el = tds . at ( i ) . element
511+ const tdDate = new Date ( + el . dataset . year , + el . dataset . month , + el . textContent )
512+ const expectDate = new Date ( disabledDays [ i ] )
513+ expect ( tdDate ) . toEqual ( expectDate )
516514 }
517515 } )
518516
0 commit comments