@@ -19,7 +19,6 @@ import { DisplayDensity } from '../core/density';
1919import { AbsoluteScrollStrategy , ConnectedPositioningStrategy } from '../services/public_api' ;
2020import { IgxSelectionAPIService } from '../core/selection' ;
2121import { IgxIconService } from '../icon/public_api' ;
22- import { CancelableEventArgs } from '../core/utils' ;
2322
2423const CSS_CLASS_COMBO = 'igx-combo' ;
2524const CSS_CLASS_COMBO_DROPDOWN = 'igx-combo__drop-down' ;
@@ -584,6 +583,38 @@ describe('igxCombo', () => {
584583 expect ( combo . onSearchInput . emit ) . toHaveBeenCalledTimes ( 1 ) ;
585584 expect ( matchSpy ) . toHaveBeenCalledTimes ( 1 ) ;
586585 } ) ;
586+ it ( 'should not open on click if combo is disabled' , ( ) => {
587+ combo = new IgxComboComponent ( elementRef , mockCdr , mockSelection as any , mockComboService ,
588+ mockIconService , null , mockInjector ) ;
589+ const dropdown = jasmine . createSpyObj ( 'IgxComboDropDownComponent' , [ 'open' , 'close' , 'toggle' ] ) ;
590+ const spyObj = jasmine . createSpyObj ( 'event' , [ 'stopPropagation' , 'preventDefault' ] ) ;
591+ spyOn ( mockIconService , 'addSvgIconFromText' ) . and . returnValue ( null ) ;
592+ combo . ngOnInit ( ) ;
593+ combo . dropdown = dropdown ;
594+ dropdown . collapsed = true ;
595+
596+ combo . disabled = true ;
597+ combo . onInputClick ( spyObj ) ;
598+ expect ( combo . dropdown . collapsed ) . toBeTruthy ( ) ;
599+ } ) ;
600+ it ( 'should not clear value when combo is disabled' , ( ) => {
601+ const selectionService = new IgxSelectionAPIService ( ) ;
602+ combo = new IgxComboComponent ( elementRef , mockCdr , selectionService , mockComboService ,
603+ mockIconService , null , mockInjector ) ;
604+ const dropdown = jasmine . createSpyObj ( 'IgxComboDropDownComponent' , [ 'selectItem' ] ) ;
605+ const spyObj = jasmine . createSpyObj ( 'event' , [ 'stopPropagation' ] ) ;
606+ spyOn ( mockIconService , 'addSvgIconFromText' ) . and . returnValue ( null ) ;
607+ combo . ngOnInit ( ) ;
608+ combo . data = data ;
609+ combo . dropdown = dropdown ;
610+ combo . disabled = true ;
611+ spyOnProperty ( combo , 'totalItemCount' ) . and . returnValue ( combo . data . length ) ;
612+
613+ const item = combo . data . slice ( 0 , 1 ) ;
614+ combo . selectItems ( item , true ) ;
615+ combo . handleClearItems ( spyObj ) ;
616+ expect ( combo . value ) . toEqual ( item [ 0 ] ) ;
617+ } ) ;
587618 } ) ;
588619 describe ( 'Initialization and rendering tests: ' , ( ) => {
589620 configureTestSuite ( ) ;
@@ -2523,13 +2554,6 @@ describe('igxCombo', () => {
25232554 expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
25242555 expect ( combo . comboInput . valid ) . toEqual ( IgxInputState . INITIAL ) ;
25252556 } ) ;
2526- it ( 'should not open on click if combo is disabled' , ( ) => {
2527- combo . disabled = true ;
2528- fixture . detectChanges ( ) ;
2529- UIInteractions . simulateClickEvent ( combo . comboInput . nativeElement ) ;
2530- fixture . detectChanges ( ) ;
2531- expect ( combo . dropdown . collapsed ) . toBeTruthy ( ) ;
2532- } ) ;
25332557 it ( 'should be possible to be enabled/disabled when used as a form control' , ( ) => {
25342558 const form = fixture . componentInstance . reactiveForm ;
25352559 const comboFormReference = form . controls . townCombo ;
0 commit comments