@@ -19,7 +19,6 @@ import { configureTestSuite } from '../test-utils/configure-suite';
1919import { DisplayDensity } from '../core/density' ;
2020import { AbsoluteScrollStrategy , ConnectedPositioningStrategy } from '../services/public_api' ;
2121import { IgxSelectionAPIService } from '../core/selection' ;
22- import { CancelableEventArgs } from '../core/utils' ;
2322
2423const CSS_CLASS_COMBO = 'igx-combo' ;
2524const CSS_CLASS_COMBO_DROPDOWN = 'igx-combo__drop-down' ;
@@ -564,6 +563,34 @@ describe('igxCombo', () => {
564563 expect ( combo . onSearchInput . emit ) . toHaveBeenCalledTimes ( 1 ) ;
565564 expect ( matchSpy ) . toHaveBeenCalledTimes ( 1 ) ;
566565 } ) ;
566+ it ( 'should not open on click if combo is disabled' , ( ) => {
567+ combo = new IgxComboComponent ( { nativeElement : null } , mockCdr , mockSelection as any , mockComboService , null , mockInjector ) ;
568+ const dropdown = jasmine . createSpyObj ( 'IgxComboDropDownComponent' , [ 'open' , 'close' , 'toggle' ] ) ;
569+ const spyObj = jasmine . createSpyObj ( 'event' , [ 'stopPropagation' , 'preventDefault' ] ) ;
570+ combo . ngOnInit ( ) ;
571+ combo . dropdown = dropdown ;
572+ dropdown . collapsed = true ;
573+
574+ combo . disabled = true ;
575+ combo . onInputClick ( spyObj ) ;
576+ expect ( combo . dropdown . collapsed ) . toBeTruthy ( ) ;
577+ } ) ;
578+ it ( 'should not clear value when combo is disabled' , ( ) => {
579+ const selectionService = new IgxSelectionAPIService ( ) ;
580+ combo = new IgxComboComponent ( { nativeElement : null } , mockCdr , selectionService , mockComboService , null , mockInjector ) ;
581+ const dropdown = jasmine . createSpyObj ( 'IgxComboDropDownComponent' , [ 'selectItem' ] ) ;
582+ const spyObj = jasmine . createSpyObj ( 'event' , [ 'stopPropagation' ] ) ;
583+ combo . ngOnInit ( ) ;
584+ combo . data = data ;
585+ combo . dropdown = dropdown ;
586+ combo . disabled = true ;
587+ spyOnProperty ( combo , 'totalItemCount' ) . and . returnValue ( combo . data . length ) ;
588+
589+ const item = combo . data . slice ( 0 , 1 ) ;
590+ combo . selectItems ( item , true ) ;
591+ combo . handleClearItems ( spyObj ) ;
592+ expect ( combo . value ) . toEqual ( item [ 0 ] ) ;
593+ } ) ;
567594 } ) ;
568595 describe ( 'Initialization and rendering tests: ' , ( ) => {
569596 configureTestSuite ( ) ;
@@ -2469,13 +2496,6 @@ describe('igxCombo', () => {
24692496 expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
24702497 expect ( combo . comboInput . valid ) . toEqual ( IgxInputState . INITIAL ) ;
24712498 } ) ;
2472- it ( 'should not open on click if combo is disabled' , ( ) => {
2473- combo . disabled = true ;
2474- fixture . detectChanges ( ) ;
2475- UIInteractions . simulateClickEvent ( combo . comboInput . nativeElement ) ;
2476- fixture . detectChanges ( ) ;
2477- expect ( combo . dropdown . collapsed ) . toBeTruthy ( ) ;
2478- } ) ;
24792499 it ( 'should be possible to be enabled/disabled when used as a form control' , ( ) => {
24802500 const form = fixture . componentInstance . reactiveForm ;
24812501 const comboFormReference = form . controls . townCombo ;
0 commit comments