@@ -15,6 +15,7 @@ import { IgxSuffixDirective } from './../directives/suffix/suffix.directive';
1515import { DisplayDensity } from '../core/displayDensity' ;
1616import { UIInteractions , wait } from '../test-utils/ui-interactions.spec' ;
1717import { configureTestSuite } from '../test-utils/configure-suite' ;
18+ import { ControlsFunction } from '../test-utils/controls-functions.spec' ;
1819
1920@Component ( {
2021 template : `
@@ -129,7 +130,7 @@ describe('IgxChip', () => {
129130
130131 it ( 'should render remove button when enabled after the content inside the chip' , ( ) => {
131132 const chipElems = fix . debugElement . queryAll ( By . directive ( IgxChipComponent ) ) ;
132- const chipRemoveButton = HelperTestFunctions . getDeleteButton ( fix ) ;
133+ const chipRemoveButton = ControlsFunction . getChipRemoveButton ( chipElems [ 1 ] . nativeElement ) ;
133134
134135 // For this second chip there are 3 elements. The prefix, content span and the remove button icon .
135136 expect ( chipElems [ 1 ] . nativeElement . children [ 0 ] . children . length ) . toEqual ( 4 ) ;
@@ -241,10 +242,10 @@ describe('IgxChip', () => {
241242
242243 it ( 'should delete chip when space button is pressed on delete button' , ( ) => {
243244 HelperTestFunctions . verifyChipsCount ( fix , 4 ) ;
244-
245- const deleteButtonElement = HelperTestFunctions . getDeleteButton ( fix ) ;
245+ const chipElems = fix . debugElement . queryAll ( By . directive ( IgxChipComponent ) ) ;
246+ const deleteButtonElement = ControlsFunction . getChipRemoveButton ( chipElems [ 1 ] . nativeElement ) ;
246247 // Removes chip with id City, because country chip is unremovable
247- UIInteractions . triggerKeyDownEvtUponElem ( ' ' , deleteButtonElement . nativeElement , true ) ;
248+ UIInteractions . triggerKeyDownEvtUponElem ( ' ' , deleteButtonElement , true ) ;
248249 fix . detectChanges ( ) ;
249250
250251 HelperTestFunctions . verifyChipsCount ( fix , 3 ) ;
@@ -257,9 +258,10 @@ describe('IgxChip', () => {
257258 it ( 'should delete chip when enter button is pressed on delete button' , ( ) => {
258259 HelperTestFunctions . verifyChipsCount ( fix , 4 ) ;
259260
260- const deleteButtonElement = HelperTestFunctions . getDeleteButton ( fix ) ;
261+ const chipElems = fix . debugElement . queryAll ( By . directive ( IgxChipComponent ) ) ;
262+ const deleteButtonElement = ControlsFunction . getChipRemoveButton ( chipElems [ 1 ] . nativeElement ) ;
261263 // Removes chip with id City, because country chip is unremovable
262- UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , deleteButtonElement . nativeElement , true ) ;
264+ UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , deleteButtonElement , true ) ;
263265 fix . detectChanges ( ) ;
264266
265267 HelperTestFunctions . verifyChipsCount ( fix , 3 ) ;
@@ -360,7 +362,8 @@ describe('IgxChip', () => {
360362 spyOn ( secondChipComp . onSelection , 'emit' ) ;
361363 spyOn ( secondChipComp . onSelectionDone , 'emit' ) ;
362364
363- const chipRemoveButton = HelperTestFunctions . getDeleteButton ( fix ) . nativeElement ;
365+ const chipRemoveButton = ControlsFunction . getChipRemoveButton ( secondChipComp . chipArea . nativeElement ) ;
366+
364367 const removeBtnTop = chipRemoveButton . getBoundingClientRect ( ) . top ;
365368 const removeBtnLeft = chipRemoveButton . getBoundingClientRect ( ) . left ;
366369
@@ -400,12 +403,6 @@ describe('IgxChip', () => {
400403} ) ;
401404
402405class HelperTestFunctions {
403- public static CHIP_REMOVE_BUTTON = '.igx-chip__remove' ;
404-
405- public static getDeleteButton ( fix , index = 0 ) {
406- return fix . debugElement . queryAll ( By . css ( HelperTestFunctions . CHIP_REMOVE_BUTTON ) ) [ index ] ;
407- }
408-
409406 public static verifyChipsCount ( fix , count ) {
410407 const chipComponents = fix . debugElement . queryAll ( By . directive ( IgxChipComponent ) ) ;
411408 expect ( chipComponents . length ) . toEqual ( count ) ;
0 commit comments