@@ -467,45 +467,93 @@ describe('Date range picker - common tests for single and two inputs mode', () =
467467 expect ( eventSpy ) . calledWith ( 'igcClosing' ) ;
468468 expect ( eventSpy ) . calledWith ( 'igcClosed' ) ;
469469 } ) ;
470- } ) ;
471- describe ( 'Interactions with the show icon' , ( ) => {
472- it ( 'should open the picker on calendar show icon click in dropdown mode' , async ( ) => {
473- simulateClick ( getIcon ( picker , toggleIcon ) ) ;
474- await elementUpdated ( picker ) ;
475470
476- expect ( picker . open ) . to . be . true ;
477- } ) ;
478- it ( 'should open the picker on calendar show icon click in dialog mode' , async ( ) => {
479- picker . mode = 'dialog' ;
480- await elementUpdated ( picker ) ;
471+ describe ( 'Interactions with the show icon' , ( ) => {
472+ it ( 'should open the picker on calendar show icon click in dropdown mode' , async ( ) => {
473+ simulateClick ( getIcon ( picker , toggleIcon ) ) ;
474+ await elementUpdated ( picker ) ;
481475
482- simulateClick ( getIcon ( picker , toggleIcon ) ) ;
483- await elementUpdated ( picker ) ;
476+ expect ( picker . open ) . to . be . true ;
477+ } ) ;
478+ it ( 'should open the picker on calendar show icon click in dialog mode' , async ( ) => {
479+ picker . mode = 'dialog' ;
480+ await elementUpdated ( picker ) ;
484481
485- expect ( picker . open ) . to . be . true ;
486- } ) ;
487- it ( 'should not open the picker on calendar show icon click in dropdown mode when readOnly is true' , async ( ) => {
488- picker . readOnly = true ;
489- await elementUpdated ( picker ) ;
482+ simulateClick ( getIcon ( picker , toggleIcon ) ) ;
483+ await elementUpdated ( picker ) ;
490484
491- simulateClick ( getIcon ( picker , toggleIcon ) ) ;
492- await elementUpdated ( picker ) ;
493-
494- expect ( picker . open ) . to . be . false ;
485+ expect ( picker . open ) . to . be . true ;
486+ } ) ;
495487 } ) ;
496- it ( 'should not open the picker on calendar show icon click in dialog mode when readOnly is true' , async ( ) => {
497- picker . mode = 'dialog' ;
498- picker . readOnly = true ;
499- await elementUpdated ( picker ) ;
500-
501- simulateClick ( getIcon ( picker , toggleIcon ) ) ;
502- await elementUpdated ( picker ) ;
503-
504- expect ( picker . open ) . to . be . false ;
488+ } ) ;
489+ describe ( 'Readonly state' , ( ) => {
490+ describe ( 'Dropdown mode' , ( ) => {
491+ beforeEach ( async ( ) => {
492+ picker . readOnly = true ;
493+ picker . value = { start : today . native , end : tomorrow . native } ;
494+ await elementUpdated ( picker ) ;
495+ } ) ;
496+
497+ it ( 'should not show the picker on calendar icon click' , async ( ) => {
498+ simulateClick ( getIcon ( picker , toggleIcon ) ) ;
499+ await elementUpdated ( picker ) ;
500+
501+ expect ( picker . open ) . to . be . false ;
502+ } ) ;
503+
504+ it ( 'should not show the picker on keyboard shortcut' , async ( ) => {
505+ simulateKeyboard ( picker , [ altKey , arrowDown ] ) ;
506+ await elementUpdated ( picker ) ;
507+
508+ expect ( picker . open ) . to . be . false ;
509+ } ) ;
510+
511+ it ( 'should not clear the value by clicking on the clear icon' , async ( ) => {
512+ simulateClick ( getIcon ( picker , toggleIcon ) ) ;
513+ await elementUpdated ( picker ) ;
514+
515+ checkSelectedRange (
516+ picker ,
517+ { start : today . native , end : tomorrow . native } ,
518+ false
519+ ) ;
520+ } ) ;
521+ } ) ;
522+ describe ( 'Dialog mode' , ( ) => {
523+ beforeEach ( async ( ) => {
524+ picker . readOnly = true ;
525+ picker . mode = 'dialog' ;
526+ picker . value = { start : today . native , end : tomorrow . native } ;
527+ await elementUpdated ( picker ) ;
528+ } ) ;
529+
530+ it ( 'should not show the picker on calendar icon click' , async ( ) => {
531+ simulateClick ( getIcon ( picker , toggleIcon ) ) ;
532+ await elementUpdated ( picker ) ;
533+
534+ expect ( picker . open ) . to . be . false ;
535+ } ) ;
536+
537+ it ( 'should not show the picker on keyboard shortcut' , async ( ) => {
538+ simulateKeyboard ( picker , [ altKey , arrowDown ] ) ;
539+ await elementUpdated ( picker ) ;
540+
541+ expect ( picker . open ) . to . be . false ;
542+ } ) ;
543+
544+ it ( 'should not clear the value by clicking on the clear icon' , async ( ) => {
545+ simulateClick ( getIcon ( picker , toggleIcon ) ) ;
546+ await elementUpdated ( picker ) ;
547+
548+ checkSelectedRange (
549+ picker ,
550+ { start : today . native , end : tomorrow . native } ,
551+ false
552+ ) ;
553+ } ) ;
505554 } ) ;
506555 } ) ;
507556 } ) ;
508- //TODO - check that the component is rendered, etc.
509557 describe ( 'Predefined ranges' , ( ) => {
510558 const previousThreeDaysStart = CalendarDay . today . add ( 'day' , - 3 ) . native ;
511559 const nextThreeDaysEnd = CalendarDay . today . add ( 'day' , 3 ) . native ;
0 commit comments