@@ -264,7 +264,7 @@ describe('igxCombo', () => {
264
264
fix . detectChanges ( ) ;
265
265
expect ( document . activeElement ) . toEqual ( combo . searchInput . nativeElement ) ;
266
266
expect ( combo . collapsed ) . toBeFalsy ( ) ;
267
- combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'ArrowDown' } ) ) ;
267
+ combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'ArrowDown' } ) ) ;
268
268
fix . detectChanges ( ) ;
269
269
expect ( dropdown . focusedItem ) . toBeTruthy ( ) ;
270
270
expect ( dropdown . focusedItem . itemIndex ) . toEqual ( 0 ) ;
@@ -274,7 +274,7 @@ describe('igxCombo', () => {
274
274
tick ( ) ;
275
275
fix . detectChanges ( ) ;
276
276
expect ( document . activeElement ) . toEqual ( combo . searchInput . nativeElement ) ;
277
- combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'ArrowDown' } ) ) ;
277
+ combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'ArrowDown' } ) ) ;
278
278
fix . detectChanges ( ) ;
279
279
expect ( dropdown . focusedItem ) . toBeTruthy ( ) ;
280
280
expect ( dropdown . focusedItem . itemIndex ) . toEqual ( 0 ) ;
@@ -293,7 +293,7 @@ describe('igxCombo', () => {
293
293
expect ( IgxDropDownBase . prototype . navigatePrev ) . toHaveBeenCalledTimes ( 1 ) ;
294
294
} ) ) ;
295
295
296
- it ( 'Should properly call dropdown navigateNext with virutal items' , ( async ( ) => {
296
+ it ( 'Should properly call dropdown navigateNext with virutal items' , ( async ( ) => {
297
297
const fix = TestBed . createComponent ( IgxComboSampleComponent ) ;
298
298
fix . detectChanges ( ) ;
299
299
const combo = fix . componentInstance . combo ;
@@ -463,19 +463,19 @@ describe('igxCombo', () => {
463
463
spyOn ( combo , 'selectAllItems' ) ;
464
464
spyOn ( combo , 'toggle' ) ;
465
465
spyOn ( combo . dropdown , 'onFocus' ) . and . callThrough ( ) ;
466
- combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'A' } ) ) ;
466
+ combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'A' } ) ) ;
467
467
combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { } ) ) ;
468
468
expect ( combo . selectAllItems ) . toHaveBeenCalledTimes ( 0 ) ;
469
469
expect ( combo . dropdown . onFocus ) . toHaveBeenCalledTimes ( 0 ) ;
470
- combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'Enter' } ) ) ;
470
+ combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'Enter' } ) ) ;
471
471
expect ( combo . selectAllItems ) . toHaveBeenCalledTimes ( 0 ) ;
472
472
spyOnProperty ( combo , 'filteredData' , 'get' ) . and . returnValue ( [ 1 ] ) ;
473
- combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'Enter' } ) ) ;
473
+ combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'Enter' } ) ) ;
474
474
expect ( combo . selectAllItems ) . toHaveBeenCalledTimes ( 0 ) ;
475
- combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'ArrowDown' } ) ) ;
475
+ combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'ArrowDown' } ) ) ;
476
476
expect ( combo . selectAllItems ) . toHaveBeenCalledTimes ( 0 ) ;
477
477
expect ( combo . dropdown . onFocus ) . toHaveBeenCalledTimes ( 1 ) ;
478
- combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'Escape' } ) ) ;
478
+ combo . handleKeyUp ( new KeyboardEvent ( 'keyup' , { key : 'Escape' } ) ) ;
479
479
expect ( combo . toggle ) . toHaveBeenCalledTimes ( 1 ) ;
480
480
} ) ) ;
481
481
it ( 'Dropdown button should open/close dropdown list' , fakeAsync ( ( ) => {
@@ -1384,7 +1384,7 @@ describe('igxCombo', () => {
1384
1384
fixture . detectChanges ( ) ;
1385
1385
const dropdownList = fixture . debugElement . query ( By . css ( '.' + CSS_CLASS_DROPDOWNLIST ) ) . nativeElement ;
1386
1386
const verifyOnSelectionChangeEventIsFired = function ( itemIndex : number ) {
1387
- const dropdownItems = fixture . debugElement . queryAll ( By . css ( '.' + CSS_CLASS_DROPDOWNLISTITEM ) ) ;
1387
+ const dropdownItems = fixture . debugElement . queryAll ( By . css ( '.' + CSS_CLASS_DROPDOWNLISTITEM ) ) ;
1388
1388
const checkbox = dropdownItems [ itemIndex ] ;
1389
1389
checkbox . triggerEventHandler ( 'click' , mockEvent ) ;
1390
1390
fixture . detectChanges ( ) ;
@@ -1545,21 +1545,17 @@ describe('igxCombo', () => {
1545
1545
1546
1546
describe ( 'Rendering tests: ' , ( ) => {
1547
1547
it ( 'Should apply all appropriate classes on combo initialization' , ( ) => {
1548
- const defaultComboWidth = '100%' ;
1549
- const defaultComboDDWidth = '100%' ;
1550
1548
const fix = TestBed . createComponent ( IgxComboScrollTestComponent ) ;
1551
1549
fix . detectChanges ( ) ;
1552
1550
1553
1551
const comboWrapper = fix . nativeElement . querySelector ( CSS_CLASS_COMBO ) ;
1554
1552
expect ( comboWrapper ) . not . toBeNull ( ) ;
1555
- expect ( comboWrapper . style . width ) . toEqual ( defaultComboWidth ) ;
1556
1553
expect ( comboWrapper . attributes . getNamedItem ( 'ng-reflect-placeholder' ) . nodeValue ) . toEqual ( 'Items' ) ;
1557
1554
expect ( comboWrapper . attributes . getNamedItem ( 'ng-reflect-data' ) . nodeValue ) . toEqual ( 'Item 1,Item 2,Item 3' ) ;
1558
1555
expect ( comboWrapper . attributes . getNamedItem ( 'ng-reflect-filterable' ) ) . toBeTruthy ( ) ;
1559
1556
expect ( comboWrapper . childElementCount ) . toEqual ( 2 ) ; // Input Group + Dropdown
1560
1557
expect ( comboWrapper . attributes . getNamedItem ( 'class' ) . nodeValue ) . toEqual ( CSS_CLASS_COMBO ) ;
1561
1558
expect ( comboWrapper . attributes . getNamedItem ( 'role' ) . nodeValue ) . toEqual ( 'combobox' ) ;
1562
- expect ( comboWrapper . style . width ) . toEqual ( defaultComboWidth ) ;
1563
1559
expect ( comboWrapper . attributes . getNamedItem ( 'aria-haspopup' ) . nodeValue ) . toEqual ( 'listbox' ) ;
1564
1560
expect ( comboWrapper . attributes . getNamedItem ( 'aria-expanded' ) . nodeValue ) . toEqual ( 'false' ) ;
1565
1561
expect ( comboWrapper . attributes . getNamedItem ( 'aria-owns' ) . nodeValue ) . toEqual ( fix . componentInstance . combo . dropdown . id ) ;
@@ -1602,13 +1598,11 @@ describe('igxCombo', () => {
1602
1598
const dropDownElement = comboWrapper . children [ 1 ] ;
1603
1599
expect ( dropDownElement . classList . contains ( CSS_CLASS_COMBO_DROPDOWN ) ) . toBeTruthy ( ) ;
1604
1600
expect ( dropDownElement . classList . contains ( CSS_CLASS_DROPDOWN ) ) . toBeTruthy ( ) ;
1605
- expect ( dropDownElement . attributes . getNamedItem ( 'ng-reflect-width' ) . nodeValue ) . toEqual ( defaultComboDDWidth ) ;
1606
1601
expect ( dropDownElement . childElementCount ) . toEqual ( 1 ) ;
1607
1602
1608
1603
const dropDownList = dropDownElement . children [ 0 ] ;
1609
1604
expect ( dropDownList . classList . contains ( CSS_CLASS_DROPDOWNLIST ) ) . toBeTruthy ( ) ;
1610
1605
expect ( dropDownList . classList . contains ( 'igx-toggle--hidden' ) ) . toBeTruthy ( ) ;
1611
- expect ( dropDownList . style . width ) . toEqual ( defaultComboDDWidth ) ;
1612
1606
expect ( dropDownList . childElementCount ) . toEqual ( 0 ) ;
1613
1607
} ) ;
1614
1608
it ( 'Should render aria attribute properly' , fakeAsync ( ( ) => {
@@ -2070,7 +2064,7 @@ describe('igxCombo', () => {
2070
2064
verifyComboData ( ) ;
2071
2065
// index is at bottom
2072
2066
expect ( combo . dropdown . verticalScrollContainer . state . startIndex + combo . dropdown . verticalScrollContainer . state . chunkSize - 1 )
2073
- . toEqual ( productIndex ) ;
2067
+ . toEqual ( productIndex ) ;
2074
2068
await wait ( 20 ) ;
2075
2069
2076
2070
productIndex = 485 ;
@@ -2080,7 +2074,7 @@ describe('igxCombo', () => {
2080
2074
verifyComboData ( ) ;
2081
2075
// index is at bottom
2082
2076
expect ( combo . dropdown . verticalScrollContainer . state . startIndex + combo . dropdown . verticalScrollContainer . state . chunkSize - 1 )
2083
- . toEqual ( productIndex ) ;
2077
+ . toEqual ( productIndex ) ;
2084
2078
await wait ( 20 ) ;
2085
2079
2086
2080
productIndex = 873 ;
@@ -2883,7 +2877,7 @@ describe('igxCombo', () => {
2883
2877
expect ( combo . value ) . toEqual ( 'My New Custom Item' ) ;
2884
2878
} ) ) ;
2885
2879
2886
- it ( 'Disable/Enable filtering at runtime' , fakeAsync ( ( ) => {
2880
+ it ( 'Disable/Enable filtering at runtime' , fakeAsync ( ( ) => {
2887
2881
const fix = TestBed . createComponent ( IgxComboInputTestComponent ) ;
2888
2882
fix . detectChanges ( ) ;
2889
2883
const combo = fix . componentInstance . combo ;
@@ -2954,7 +2948,7 @@ describe('igxCombo', () => {
2954
2948
2955
2949
describe ( 'Form control tests: ' , ( ) => {
2956
2950
2957
- it ( 'Should properly initialize when used as a form control' , fakeAsync ( ( ) => {
2951
+ it ( 'Should properly initialize when used as a form control' , fakeAsync ( ( ) => {
2958
2952
const fix = TestBed . createComponent ( IgxComboFormComponent ) ;
2959
2953
fix . detectChanges ( ) ;
2960
2954
const combo = fix . componentInstance . combo ;
@@ -2969,8 +2963,47 @@ describe('igxCombo', () => {
2969
2963
clearButton . click ( ) ;
2970
2964
fix . detectChanges ( ) ;
2971
2965
expect ( combo . valid ) . toEqual ( IgxComboState . INVALID ) ;
2966
+
2967
+ combo . onBlur ( ) ;
2968
+ fix . detectChanges ( ) ;
2969
+ expect ( combo . valid ) . toEqual ( IgxComboState . INVALID ) ;
2970
+
2972
2971
combo . selectItems ( [ combo . dropdown . items [ 0 ] , combo . dropdown . items [ 1 ] ] ) ;
2973
2972
expect ( combo . valid ) . toEqual ( IgxComboState . VALID ) ;
2973
+
2974
+ combo . onBlur ( ) ;
2975
+ fix . detectChanges ( ) ;
2976
+ expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
2977
+ } ) ) ;
2978
+
2979
+ it ( 'Should properly initialize when used as a form control - without validators' , fakeAsync ( ( ) => {
2980
+ const fix = TestBed . createComponent ( IgxComboFormComponent ) ;
2981
+ fix . detectChanges ( ) ;
2982
+ const combo = fix . componentInstance . combo ;
2983
+ const form : FormGroup = fix . componentInstance . reactiveForm ;
2984
+ form . controls . townCombo . validator = null ;
2985
+ expect ( combo ) . toBeDefined ( ) ;
2986
+ const comboFormReference = fix . componentInstance . reactiveForm . controls . townCombo ;
2987
+ expect ( comboFormReference ) . toBeDefined ( ) ;
2988
+ expect ( combo . selectedItems ( ) ) . toEqual ( comboFormReference . value ) ;
2989
+ expect ( combo . selectedItems ( ) . length ) . toEqual ( 1 ) ;
2990
+ expect ( combo . selectedItems ( ) [ 0 ] . field ) . toEqual ( 'Connecticut' ) ;
2991
+ expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
2992
+ const clearButton = fix . debugElement . query ( By . css ( '.' + CSS_CLASS_CLEARBUTTON ) ) . nativeElement ;
2993
+ clearButton . click ( ) ;
2994
+ fix . detectChanges ( ) ;
2995
+ expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
2996
+
2997
+ combo . onBlur ( ) ;
2998
+ fix . detectChanges ( ) ;
2999
+ expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
3000
+
3001
+ combo . selectItems ( [ combo . dropdown . items [ 0 ] , combo . dropdown . items [ 1 ] ] ) ;
3002
+ expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
3003
+
3004
+ combo . onBlur ( ) ;
3005
+ fix . detectChanges ( ) ;
3006
+ expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
2974
3007
} ) ) ;
2975
3008
2976
3009
it ( 'Should be possible to be enabled/disabled when used as a form control' , ( ) => {
@@ -2989,6 +3022,7 @@ describe('igxCombo', () => {
2989
3022
combo . comboInput . nativeElement . click ( ) ;
2990
3023
fix . detectChanges ( ) ;
2991
3024
expect ( combo . onInputClick ) . toHaveBeenCalledTimes ( 1 ) ;
3025
+ combo . comboInput . nativeElement . blur ( ) ;
2992
3026
2993
3027
form . disable ( ) ;
2994
3028
// Disabling the form disables all of the controls in it
@@ -3001,6 +3035,7 @@ describe('igxCombo', () => {
3001
3035
combo . comboInput . nativeElement . click ( ) ;
3002
3036
fix . detectChanges ( ) ;
3003
3037
expect ( combo . onInputClick ) . toHaveBeenCalledTimes ( 1 ) ;
3038
+ combo . comboInput . nativeElement . blur ( ) ;
3004
3039
3005
3040
// Can enabling the form re-enables all of the controls in it
3006
3041
form . enable ( ) ;
0 commit comments