@@ -3,7 +3,8 @@ import { async, TestBed, tick, fakeAsync } from '@angular/core/testing';
33import { By } from '@angular/platform-browser' ;
44import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
55import { FormGroup , FormControl , Validators , FormBuilder , ReactiveFormsModule , FormsModule , NgControl } from '@angular/forms' ;
6- import { IgxComboComponent , IgxComboModule , IComboSelectionChangeEventArgs , IgxComboState } from './combo.component' ;
6+ import { IgxComboComponent , IgxComboModule , IComboSelectionChangeEventArgs , IgxComboState ,
7+ IComboSearchInputEventArgs } from './combo.component' ;
78import { IgxComboItemComponent } from './combo-item.component' ;
89import { IgxComboDropDownComponent } from './combo-dropdown.component' ;
910import { IgxComboAddItemComponent } from './combo-add-item.component' ;
@@ -565,7 +566,7 @@ describe('igxCombo', () => {
565566
566567 combo . handleInputChange ( 'Item1' ) ;
567568 expect ( combo . onSearchInput . emit ) . toHaveBeenCalledTimes ( 1 ) ;
568- expect ( matchSpy ) . toHaveBeenCalledTimes ( 0 ) ;
569+ expect ( matchSpy ) . toHaveBeenCalledTimes ( 1 ) ;
569570 } ) ;
570571 } ) ;
571572 describe ( 'Initialization and rendering tests: ' , ( ) => {
@@ -637,11 +638,11 @@ describe('igxCombo', () => {
637638 expect ( inputGroupElement . classList . contains ( CSS_CLASS_INPUTGROUP ) ) . toBeTruthy ( ) ;
638639 expect ( inputGroupElement . classList . contains ( 'igx-input-group--box' ) ) . toBeTruthy ( ) ;
639640 expect ( inputGroupElement . classList . contains ( 'igx-input-group--placeholder' ) ) . toBeTruthy ( ) ;
640- expect ( inputGroupElement . childElementCount ) . toEqual ( 2 ) ;
641+ expect ( inputGroupElement . childElementCount ) . toEqual ( 3 ) ;
641642
642643 const inputGroupWrapper = inputGroupElement . children [ 0 ] ;
643644 expect ( inputGroupWrapper . classList . contains ( CSS_CLASS_INPUTGROUP_WRAPPER ) ) . toBeTruthy ( ) ;
644- expect ( inputGroupWrapper . childElementCount ) . toEqual ( 2 ) ;
645+ expect ( inputGroupWrapper . childElementCount ) . toEqual ( 1 ) ;
645646
646647 const inputGroupBundle = inputGroupWrapper . children [ 0 ] ;
647648 expect ( inputGroupBundle . classList . contains ( CSS_CLASS_INPUTGROUP_BUNDLE ) ) . toBeTruthy ( ) ;
@@ -660,7 +661,7 @@ describe('igxCombo', () => {
660661 expect ( dropDownButton . classList . contains ( CSS_CLASS_TOGGLEBUTTON ) ) . toBeTruthy ( ) ;
661662 expect ( dropDownButton . childElementCount ) . toEqual ( 1 ) ;
662663
663- const inputGroupBorder = inputGroupWrapper . children [ 1 ] ;
664+ const inputGroupBorder = inputGroupElement . children [ 1 ] ;
664665 expect ( inputGroupBorder . classList . contains ( CSS_CLASS_INPUTGROUP_BORDER ) ) . toBeTruthy ( ) ;
665666 expect ( inputGroupBorder . childElementCount ) . toEqual ( 0 ) ;
666667
@@ -2377,6 +2378,17 @@ describe('igxCombo', () => {
23772378 fixture . detectChanges ( ) ;
23782379 expect ( combo . isAddButtonVisible ( ) ) . toEqual ( true ) ;
23792380 } ) ;
2381+ it ( 'Should NOT filter the data when onSearchInput is canceled' , ( ) => {
2382+ const cancelSub = combo . onSearchInput . subscribe ( ( event : IComboSearchInputEventArgs ) => event . cancel = true ) ;
2383+ combo . toggle ( ) ;
2384+ fixture . detectChanges ( ) ;
2385+ const searchInput = fixture . debugElement . query ( By . css ( 'input[name=\'searchInput\']' ) ) ;
2386+ UIInteractions . triggerInputEvent ( searchInput , 'Test' ) ;
2387+ fixture . detectChanges ( ) ;
2388+ expect ( combo . filteredData . length ) . toEqual ( combo . data . length ) ;
2389+ expect ( combo . searchValue ) . toEqual ( 'Test' ) ;
2390+ cancelSub . unsubscribe ( ) ;
2391+ } ) ;
23802392 } ) ;
23812393 describe ( 'Form control tests: ' , ( ) => {
23822394 describe ( 'Reactive form tests: ' , ( ) => {
0 commit comments