@@ -178,20 +178,35 @@ public void DatePicker_Should_DateFormatTakesPrecedenceOverCulture()
178178 picker . Text . Should ( ) . Be ( "26 10 2020" ) ;
179179 }
180180
181+ [ Test ]
182+ public void ReadOnlyShouldNotHaveClearButton ( )
183+ {
184+ var comp = Context . RenderComponent < MudDatePicker > ( p => p
185+ . Add ( x => x . Text , "some value" )
186+ . Add ( x => x . Clearable , true )
187+ . Add ( x => x . ReadOnly , false ) ) ;
188+
189+ comp . FindAll ( ".mud-input-clear-button" ) . Count . Should ( ) . Be ( 1 ) ;
190+
191+ comp . SetParametersAndRender ( p => p . Add ( x => x . ReadOnly , true ) ) ; //no clear button when readonly
192+ comp . FindAll ( ".mud-input-clear-button" ) . Count . Should ( ) . Be ( 0 ) ;
193+ }
194+
181195 [ Test ]
182196 public void DatePicker_Should_Clear ( )
183197 {
184198 var comp = Context . RenderComponent < MudDatePicker > ( ) ;
185199 // select elements needed for the test
186200 var picker = comp . Instance ;
187- picker . Text . Should ( ) . Be ( null ) ;
201+ picker . ReadOnly . Should ( ) . Be ( false ) ;
188202 picker . Date . Should ( ) . Be ( null ) ;
203+ picker . Text . Should ( ) . Be ( null ) ;
189204 comp . SetParam ( p => p . Clearable , true ) ;
190205 comp . SetParam ( p => p . Date , new DateTime ( 2020 , 10 , 26 ) ) ;
191206 picker . Date . Should ( ) . Be ( new DateTime ( 2020 , 10 , 26 ) ) ;
192207 picker . Text . Should ( ) . Be ( new DateTime ( 2020 , 10 , 26 ) . ToShortDateString ( ) ) ;
193208
194- comp . Find ( "button" ) . Click ( ) ; //clear the input
209+ comp . Find ( ".mud-input-clear- button" ) . Click ( ) ; //clear the input
195210
196211 picker . Text . Should ( ) . Be ( "" ) ; //ensure the text and date are reset. Note this is an empty string rather than null due to how the reset works internally
197212 picker . Date . Should ( ) . Be ( null ) ;
0 commit comments