@@ -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 ( ) ;
198
+ fixture . detectChanges ( ) ;
199
+
200
+ const cancelButton = dom . query ( By . css ( '.igx-button--flat' ) ) ;
201
+ UIInteractions . clickElement ( cancelButton ) ;
202
+ tick ( ) ;
188
203
fixture . detectChanges ( ) ;
189
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 ;
@@ -1613,34 +1635,34 @@ describe('IgxTimePicker', () => {
1613
1635
} ) ) ;
1614
1636
1615
1637
it ( 'When timepicker is closed via outside click, the focus should NOT remain on the input' ,
1616
- fakeAsync ( ( ) => {
1617
- fixture . detectChanges ( ) ;
1618
- input = fixture . debugElement . query ( By . directive ( IgxInputDirective ) ) . nativeElement ;
1619
- let overlayToggle = document . getElementsByClassName ( 'igx-overlay__wrapper' ) ;
1638
+ fakeAsync ( ( ) => {
1639
+ fixture . detectChanges ( ) ;
1640
+ input = fixture . debugElement . query ( By . directive ( IgxInputDirective ) ) . nativeElement ;
1641
+ let overlayToggle = document . getElementsByClassName ( 'igx-overlay__wrapper' ) ;
1620
1642
1621
- expect ( overlayToggle . length ) . toEqual ( 0 ) ;
1643
+ expect ( overlayToggle . length ) . toEqual ( 0 ) ;
1622
1644
1623
- const iconTime = dom . queryAll ( By . css ( '.igx-icon' ) ) [ 0 ] ;
1624
- UIInteractions . clickElement ( iconTime ) ;
1625
- tick ( ) ;
1626
- fixture . detectChanges ( ) ;
1645
+ const iconTime = dom . queryAll ( By . css ( '.igx-icon' ) ) [ 0 ] ;
1646
+ UIInteractions . clickElement ( iconTime ) ;
1647
+ tick ( ) ;
1648
+ fixture . detectChanges ( ) ;
1627
1649
1628
- overlayToggle = document . getElementsByClassName ( 'igx-overlay__wrapper' ) ;
1629
- expect ( overlayToggle [ 0 ] ) . not . toBeNull ( ) ;
1630
- expect ( overlayToggle [ 0 ] ) . not . toBeUndefined ( ) ;
1650
+ overlayToggle = document . getElementsByClassName ( 'igx-overlay__wrapper' ) ;
1651
+ expect ( overlayToggle [ 0 ] ) . not . toBeNull ( ) ;
1652
+ expect ( overlayToggle [ 0 ] ) . not . toBeUndefined ( ) ;
1631
1653
1632
- const dummyInput = fixture . componentInstance . dummyInput . nativeElement ;
1633
- dummyInput . focus ( ) ;
1634
- dummyInput . click ( ) ;
1635
- tick ( ) ;
1636
- fixture . detectChanges ( ) ;
1654
+ const dummyInput = fixture . componentInstance . dummyInput . nativeElement ;
1655
+ dummyInput . focus ( ) ;
1656
+ dummyInput . click ( ) ;
1657
+ tick ( ) ;
1658
+ fixture . detectChanges ( ) ;
1637
1659
1638
- overlayToggle = document . getElementsByClassName ( 'igx-overlay__wrapper' ) ;
1639
- input = fixture . debugElement . query ( By . directive ( IgxInputDirective ) ) . nativeElement ;
1640
- expect ( overlayToggle [ 0 ] ) . toEqual ( undefined ) ;
1641
- expect ( input ) . not . toEqual ( document . activeElement ) ;
1642
- expect ( dummyInput ) . toEqual ( document . activeElement ) ;
1643
- } ) ) ;
1660
+ overlayToggle = document . getElementsByClassName ( 'igx-overlay__wrapper' ) ;
1661
+ input = fixture . debugElement . query ( By . directive ( IgxInputDirective ) ) . nativeElement ;
1662
+ expect ( overlayToggle [ 0 ] ) . toEqual ( undefined ) ;
1663
+ expect ( input ) . not . toEqual ( document . activeElement ) ;
1664
+ expect ( dummyInput ) . toEqual ( document . activeElement ) ;
1665
+ } ) ) ;
1644
1666
} ) ;
1645
1667
1646
1668
describe ( 'Timepicker with outlet' , ( ) => {
@@ -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