@@ -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' ;
@@ -602,6 +601,38 @@ describe('igxCombo', () => {
602601 expect ( combo . onSearchInput . emit ) . toHaveBeenCalledTimes ( 1 ) ;
603602 expect ( matchSpy ) . toHaveBeenCalledTimes ( 1 ) ;
604603 } ) ;
604+ it ( 'should not open on click if combo is disabled' , ( ) => {
605+ combo = new IgxComboComponent ( elementRef , mockCdr , mockSelection as any , mockComboService ,
606+ mockIconService , null , null , mockInjector ) ;
607+ const dropdown = jasmine . createSpyObj ( 'IgxComboDropDownComponent' , [ 'open' , 'close' , 'toggle' ] ) ;
608+ const spyObj = jasmine . createSpyObj ( 'event' , [ 'stopPropagation' , 'preventDefault' ] ) ;
609+ spyOn ( mockIconService , 'addSvgIconFromText' ) . and . returnValue ( null ) ;
610+ combo . ngOnInit ( ) ;
611+ combo . dropdown = dropdown ;
612+ dropdown . collapsed = true ;
613+
614+ combo . disabled = true ;
615+ combo . onInputClick ( spyObj ) ;
616+ expect ( combo . dropdown . collapsed ) . toBeTruthy ( ) ;
617+ } ) ;
618+ it ( 'should not clear value when combo is disabled' , ( ) => {
619+ const selectionService = new IgxSelectionAPIService ( ) ;
620+ combo = new IgxComboComponent ( elementRef , mockCdr , selectionService , mockComboService ,
621+ mockIconService , null , null , mockInjector ) ;
622+ const dropdown = jasmine . createSpyObj ( 'IgxComboDropDownComponent' , [ 'selectItem' ] ) ;
623+ const spyObj = jasmine . createSpyObj ( 'event' , [ 'stopPropagation' ] ) ;
624+ spyOn ( mockIconService , 'addSvgIconFromText' ) . and . returnValue ( null ) ;
625+ combo . ngOnInit ( ) ;
626+ combo . data = data ;
627+ combo . dropdown = dropdown ;
628+ combo . disabled = true ;
629+ spyOnProperty ( combo , 'totalItemCount' ) . and . returnValue ( combo . data . length ) ;
630+
631+ const item = combo . data . slice ( 0 , 1 ) ;
632+ combo . selectItems ( item , true ) ;
633+ combo . handleClearItems ( spyObj ) ;
634+ expect ( combo . value ) . toEqual ( item [ 0 ] ) ;
635+ } ) ;
605636 } ) ;
606637 describe ( 'Initialization and rendering tests: ' , ( ) => {
607638 configureTestSuite ( ) ;
@@ -2541,13 +2572,6 @@ describe('igxCombo', () => {
25412572 expect ( combo . valid ) . toEqual ( IgxComboState . INITIAL ) ;
25422573 expect ( combo . comboInput . valid ) . toEqual ( IgxInputState . INITIAL ) ;
25432574 } ) ;
2544- it ( 'should not open on click if combo is disabled' , ( ) => {
2545- combo . disabled = true ;
2546- fixture . detectChanges ( ) ;
2547- UIInteractions . simulateClickEvent ( combo . comboInput . nativeElement ) ;
2548- fixture . detectChanges ( ) ;
2549- expect ( combo . dropdown . collapsed ) . toBeTruthy ( ) ;
2550- } ) ;
25512575 it ( 'should be possible to be enabled/disabled when used as a form control' , ( ) => {
25522576 const form = fixture . componentInstance . reactiveForm ;
25532577 const comboFormReference = form . controls . townCombo ;
0 commit comments