@@ -147,31 +147,6 @@ describe('Date range picker - two inputs', () => {
147147 checkSelectedRange ( picker , expectedValue ) ;
148148 } ) ;
149149
150- it ( 'should not modify value through selection or typing when readOnly is true' , async ( ) => {
151- const eventSpy = spy ( picker , 'emitEvent' ) ;
152- picker . readOnly = true ;
153- await elementUpdated ( picker ) ;
154- expect ( picker . value ) . to . deep . equal ( { start : null , end : null } ) ;
155-
156- await picker . show ( ) ;
157- await selectDates ( today , tomorrow , calendar ) ;
158-
159- expect ( picker . value ) . to . deep . equal ( { start : null , end : null } ) ;
160- expect ( calendar . values ) . to . deep . equal ( [ ] ) ;
161- expect ( eventSpy ) . not . to . be . called ;
162-
163- await picker . hide ( ) ;
164-
165- dateTimeInputs [ 0 ] . focus ( ) ;
166- simulateKeyboard ( dateTimeInputs [ 0 ] , 'ArrowDown' ) ;
167- await elementUpdated ( picker ) ;
168- expect ( isFocused ( dateTimeInputs [ 0 ] ) ) . to . be . true ;
169- expect ( dateTimeInputs [ 0 ] . value ) . to . equal ( null ) ;
170- expect ( picker . value ) . to . deep . equal ( { start : null , end : null } ) ;
171- expect ( calendar . values ) . to . deep . equal ( [ ] ) ;
172- expect ( eventSpy ) . not . to . be . called ;
173- } ) ;
174-
175150 it ( 'should modify value only through calendar selection and not input when nonEditable is true' , async ( ) => {
176151 const eventSpy = spy ( picker , 'emitEvent' ) ;
177152 picker . nonEditable = true ;
@@ -601,20 +576,6 @@ describe('Date range picker - two inputs', () => {
601576 expect ( dateTimeInputs [ 1 ] . value ) . to . be . null ;
602577 } ) ;
603578
604- it ( 'should not clear the inputs via the clear icon when readOnly is true' , async ( ) => {
605- const eventSpy = spy ( picker , 'emitEvent' ) ;
606- const testValue = { start : today . native , end : tomorrow . native } ;
607- picker . value = testValue ;
608- picker . readOnly = true ;
609- await elementUpdated ( picker ) ;
610-
611- simulateClick ( getIcon ( picker , clearIcon ) ) ;
612-
613- expect ( picker . value ) . to . deep . equal ( testValue ) ;
614- expect ( eventSpy ) . not . called ;
615- checkSelectedRange ( picker , testValue ) ;
616- } ) ;
617-
618579 it ( 'should emit igcInput and igcChange on input value change' , async ( ) => {
619580 const eventSpy = spy ( picker , 'emitEvent' ) ;
620581
@@ -815,6 +776,69 @@ describe('Date range picker - two inputs', () => {
815776 checkDatesEqual ( calendar . activeDate , june3rd2025 ) ;
816777 } ) ;
817778 } ) ;
779+ describe ( 'Readonly state' , ( ) => {
780+ beforeEach ( async ( ) => {
781+ picker . readOnly = true ;
782+ await elementUpdated ( picker ) ;
783+ } ) ;
784+ it ( 'should not modify value through selection or typing when readOnly is true' , async ( ) => {
785+ const eventSpy = spy ( picker , 'emitEvent' ) ;
786+ expect ( picker . value ) . to . deep . equal ( { start : null , end : null } ) ;
787+
788+ await picker . show ( ) ;
789+ await selectDates ( today , tomorrow , calendar ) ;
790+
791+ expect ( picker . value ) . to . deep . equal ( { start : null , end : null } ) ;
792+ expect ( calendar . values ) . to . deep . equal ( [ ] ) ;
793+ expect ( eventSpy ) . not . to . be . called ;
794+
795+ await picker . hide ( ) ;
796+
797+ dateTimeInputs [ 0 ] . focus ( ) ;
798+ simulateKeyboard ( dateTimeInputs [ 0 ] , 'ArrowDown' ) ;
799+ await elementUpdated ( picker ) ;
800+ expect ( isFocused ( dateTimeInputs [ 0 ] ) ) . to . be . true ;
801+ expect ( dateTimeInputs [ 0 ] . value ) . to . equal ( null ) ;
802+ expect ( picker . value ) . to . deep . equal ( { start : null , end : null } ) ;
803+ expect ( calendar . values ) . to . deep . equal ( [ ] ) ;
804+ expect ( eventSpy ) . not . to . be . called ;
805+ } ) ;
806+ it ( 'should not clear the inputs via the clear icon when readOnly is true' , async ( ) => {
807+ const eventSpy = spy ( picker , 'emitEvent' ) ;
808+ const testValue = { start : today . native , end : tomorrow . native } ;
809+ picker . value = testValue ;
810+ await elementUpdated ( picker ) ;
811+
812+ simulateClick ( getIcon ( picker , clearIcon ) ) ;
813+
814+ expect ( picker . value ) . to . deep . equal ( testValue ) ;
815+ expect ( eventSpy ) . not . called ;
816+ checkSelectedRange ( picker , testValue ) ;
817+ } ) ;
818+ it ( 'should not open the calendar on clicking the input - dropdown mode' , async ( ) => {
819+ const eventSpy = spy ( picker , 'emitEvent' ) ;
820+ const nativeInput =
821+ dateTimeInputs [ 0 ] . renderRoot . querySelector ( 'input' ) ! ;
822+ simulateClick ( nativeInput ) ;
823+ await elementUpdated ( picker ) ;
824+
825+ expect ( picker . open ) . to . be . false ;
826+ expect ( eventSpy ) . not . called ;
827+ } ) ;
828+ it ( 'should not open the calendar on clicking the input - dialog mode' , async ( ) => {
829+ const eventSpy = spy ( picker , 'emitEvent' ) ;
830+ picker . mode = 'dialog' ;
831+ await elementUpdated ( picker ) ;
832+
833+ const nativeInput =
834+ dateTimeInputs [ 0 ] . renderRoot . querySelector ( 'input' ) ! ;
835+ simulateClick ( nativeInput ) ;
836+ await elementUpdated ( picker ) ;
837+
838+ expect ( picker . open ) . to . be . false ;
839+ expect ( eventSpy ) . not . called ;
840+ } ) ;
841+ } ) ;
818842 } ) ;
819843 describe ( 'Slots' , ( ) => {
820844 it ( 'should render slotted elements' , async ( ) => {
0 commit comments