@@ -183,10 +183,32 @@ describe('IgxTimePicker', () => {
183183 expect ( timePicker . onValidationFailed . emit ) . toHaveBeenCalled ( ) ;
184184 } ) ) ;
185185
186- it ( 'TimePicker cancel button' , fakeAsync ( ( ) => {
186+ it ( 'Should display mask on cancel button click with bound null value ' , fakeAsync ( ( ) => {
187187 const fixture = TestBed . createComponent ( IgxTimePickerWithPmTimeComponent ) ;
188+ fixture . componentInstance . dateValue = null ;
189+ fixture . componentInstance . mode = 'dropdown' ;
190+ fixture . detectChanges ( ) ;
191+ const timePicker = fixture . componentInstance . timePicker ;
192+ const dom = fixture . debugElement ;
193+ const timePickerTarget = dom . query ( By . directive ( IgxInputDirective ) ) ;
194+ spyOn ( timePicker . onValidationFailed , 'emit' ) ;
195+
196+ UIInteractions . clickElement ( timePickerTarget ) ;
197+ tick ( ) ;
188198 fixture . detectChanges ( ) ;
189199
200+ const cancelButton = dom . query ( By . css ( '.igx-button--flat' ) ) ;
201+ UIInteractions . clickElement ( cancelButton ) ;
202+ tick ( ) ;
203+ fixture . detectChanges ( ) ;
204+
205+ expect ( timePicker . onValidationFailed . emit ) . not . toHaveBeenCalled ( ) ;
206+ expect ( timePicker . displayValue ) . toEqual ( '--:--:-- --' ) ;
207+ } ) ) ;
208+
209+ it ( 'TimePicker cancel button' , fakeAsync ( ( ) => {
210+ const fixture = TestBed . createComponent ( IgxTimePickerWithPmTimeComponent ) ;
211+ fixture . detectChanges ( ) ;
190212 const timePicker = fixture . componentInstance . timePicker ;
191213 const dom = fixture . debugElement ;
192214 const initialTime = dom . query ( By . directive ( IgxInputDirective ) ) . nativeElement . value ;
@@ -2024,12 +2046,13 @@ export class IgxTimePickerWithPassedTimeComponent {
20242046
20252047@Component ( {
20262048 template : `
2027- <igx-time-picker [value]="dateValue" [format]="customFormat"></igx-time-picker>
2049+ <igx-time-picker [mode]="mode" [ value]="dateValue" [format]="customFormat"></igx-time-picker>
20282050 `
20292051} )
20302052export class IgxTimePickerWithPmTimeComponent {
20312053 public dateValue : Date = new Date ( 2017 , 7 , 7 , 12 , 27 , 23 ) ;
20322054 public customFormat = 'h:mm:ss tt' ;
2055+ public mode = 'dialog' ;
20332056 @ViewChild ( IgxTimePickerComponent , { static : true } ) public timePicker : IgxTimePickerComponent ;
20342057}
20352058
0 commit comments