@@ -264,38 +264,73 @@ describe('Picker.Range', () => {
264264 } ) ;
265265 } ) ;
266266
267- it ( 'ranges' , ( ) => {
268- const onChange = jest . fn ( ) ;
269- const wrapper = mount (
270- < MomentRangePicker
271- ranges = { {
272- test : [ getMoment ( '1989-11-28' ) , getMoment ( '1990-09-03' ) ] ,
273- func : ( ) => [ getMoment ( '2000-01-01' ) , getMoment ( '2010-11-11' ) ] ,
274- } }
275- onChange = { onChange }
276- /> ,
277- ) ;
267+ describe ( 'ranges' , ( ) => {
268+ it ( 'work' , ( ) => {
269+ const onChange = jest . fn ( ) ;
270+ const wrapper = mount (
271+ < MomentRangePicker
272+ ranges = { {
273+ test : [ getMoment ( '1989-11-28' ) , getMoment ( '1990-09-03' ) ] ,
274+ func : ( ) => [ getMoment ( '2000-01-01' ) , getMoment ( '2010-11-11' ) ] ,
275+ } }
276+ onChange = { onChange }
277+ /> ,
278+ ) ;
278279
279- wrapper . openPicker ( ) ;
280- let testNode ;
280+ wrapper . openPicker ( ) ;
281+ let testNode ;
281282
282- // Basic
283- testNode = wrapper . find ( '.rc-picker-ranges li span' ) . first ( ) ;
284- expect ( testNode . text ( ) ) . toEqual ( 'test' ) ;
285- testNode . simulate ( 'click' ) ;
286- expect ( onChange ) . toHaveBeenCalledWith (
287- [ expect . anything ( ) , expect . anything ( ) ] ,
288- [ '1989-11-28' , '1990-09-03' ] ,
289- ) ;
283+ // Basic
284+ testNode = wrapper . find ( '.rc-picker-ranges li span' ) . first ( ) ;
285+ expect ( testNode . text ( ) ) . toEqual ( 'test' ) ;
286+ testNode . simulate ( 'click' ) ;
287+ expect ( onChange ) . toHaveBeenCalledWith (
288+ [ expect . anything ( ) , expect . anything ( ) ] ,
289+ [ '1989-11-28' , '1990-09-03' ] ,
290+ ) ;
290291
291- // Function
292- testNode = wrapper . find ( '.rc-picker-ranges li span' ) . last ( ) ;
293- expect ( testNode . text ( ) ) . toEqual ( 'func' ) ;
294- testNode . simulate ( 'click' ) ;
295- expect ( onChange ) . toHaveBeenCalledWith (
296- [ expect . anything ( ) , expect . anything ( ) ] ,
297- [ '2000-01-01' , '2010-11-11' ] ,
298- ) ;
292+ // Function
293+ testNode = wrapper . find ( '.rc-picker-ranges li span' ) . last ( ) ;
294+ expect ( testNode . text ( ) ) . toEqual ( 'func' ) ;
295+ testNode . simulate ( 'click' ) ;
296+ expect ( onChange ) . toHaveBeenCalledWith (
297+ [ expect . anything ( ) , expect . anything ( ) ] ,
298+ [ '2000-01-01' , '2010-11-11' ] ,
299+ ) ;
300+ } ) ;
301+
302+ it ( 'hover className' , ( ) => {
303+ const wrapper = mount (
304+ < MomentRangePicker
305+ ranges = { {
306+ now : [ getMoment ( '1990-09-11' ) , getMoment ( '1990-09-13' ) ] ,
307+ } }
308+ /> ,
309+ ) ;
310+
311+ wrapper . openPicker ( ) ;
312+ wrapper . find ( '.rc-picker-ranges li span' ) . simulate ( 'mouseEnter' ) ;
313+ expect (
314+ wrapper . findCell ( 11 ) . hasClass ( 'rc-picker-cell-range-hover-start' ) ,
315+ ) . toBeTruthy ( ) ;
316+ expect (
317+ wrapper . findCell ( 12 ) . hasClass ( 'rc-picker-cell-range-hover' ) ,
318+ ) . toBeTruthy ( ) ;
319+ expect (
320+ wrapper . findCell ( 13 ) . hasClass ( 'rc-picker-cell-range-hover-end' ) ,
321+ ) . toBeTruthy ( ) ;
322+
323+ wrapper . find ( '.rc-picker-ranges li span' ) . simulate ( 'mouseLeave' ) ;
324+ expect (
325+ wrapper . findCell ( 11 ) . hasClass ( 'rc-picker-cell-range-hover-start' ) ,
326+ ) . toBeFalsy ( ) ;
327+ expect (
328+ wrapper . findCell ( 12 ) . hasClass ( 'rc-picker-cell-range-hover' ) ,
329+ ) . toBeFalsy ( ) ;
330+ expect (
331+ wrapper . findCell ( 13 ) . hasClass ( 'rc-picker-cell-range-hover-end' ) ,
332+ ) . toBeFalsy ( ) ;
333+ } ) ;
299334 } ) ;
300335
301336 it ( 'placeholder' , ( ) => {
0 commit comments