@@ -183,10 +183,32 @@ describe('IgxTimePicker', () => {
183
183
expect ( timePicker . onValidationFailed . emit ) . toHaveBeenCalled ( ) ;
184
184
} ) ) ;
185
185
186
- it ( 'TimePicker cancel button' , fakeAsync ( ( ) => {
186
+ it ( 'Should display mask on cancel button click with bound null value ' , fakeAsync ( ( ) => {
187
187
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 ( ) ;
188
198
fixture . detectChanges ( ) ;
189
199
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 ( ) ;
190
212
const timePicker = fixture . componentInstance . timePicker ;
191
213
const dom = fixture . debugElement ;
192
214
const initialTime = dom . query ( By . directive ( IgxInputDirective ) ) . nativeElement . value ;
@@ -2024,12 +2046,13 @@ export class IgxTimePickerWithPassedTimeComponent {
2024
2046
2025
2047
@Component ( {
2026
2048
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>
2028
2050
`
2029
2051
} )
2030
2052
export class IgxTimePickerWithPmTimeComponent {
2031
2053
public dateValue : Date = new Date ( 2017 , 7 , 7 , 12 , 27 , 23 ) ;
2032
2054
public customFormat = 'h:mm:ss tt' ;
2055
+ public mode = 'dialog' ;
2033
2056
@ViewChild ( IgxTimePickerComponent , { static : true } ) public timePicker : IgxTimePickerComponent ;
2034
2057
}
2035
2058
0 commit comments