@@ -37,7 +37,6 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
37
37
import { ComponentFixture , TestBed , fakeAsync , flush , tick } from '@angular/core/testing' ;
38
38
import { FormControl , FormsModule , NgForm , ReactiveFormsModule , Validators } from '@angular/forms' ;
39
39
import { By } from '@angular/platform-browser' ;
40
- import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
41
40
import { MATERIAL_ANIMATIONS } from '../core' ;
42
41
import { MatError , MatFormField , MatHint , MatLabel } from '../form-field' ;
43
42
import {
@@ -178,13 +177,14 @@ describe('MatChipGrid', () => {
178
177
179
178
describe ( 'on chip destroy' , ( ) => {
180
179
it ( 'should focus the next item' , ( ) => {
181
- // TODO(crisbeto): this test fails without the NoopAnimationsModule for some reason.
182
- // It can indicate a deeper issue with the chips.
183
- const fixture = createComponent ( StandardChipGrid , undefined , [ NoopAnimationsModule ] ) ;
184
- const midItem = chips . get ( 2 ) ! ;
180
+ const fixture = createComponent ( StandardChipGrid ) ;
181
+ const midItemAction = primaryActions [ 2 ] ;
182
+ patchElementFocus ( midItemAction ) ;
185
183
186
184
// Focus the middle item
187
- midItem . focus ( ) ;
185
+ midItemAction . focus ( ) ;
186
+ fixture . changeDetectorRef . markForCheck ( ) ;
187
+ fixture . detectChanges ( ) ;
188
188
189
189
// Destroy the middle item
190
190
testComponent . chips . splice ( 2 , 1 ) ;
@@ -196,11 +196,14 @@ describe('MatChipGrid', () => {
196
196
} ) ;
197
197
198
198
it ( 'should focus the previous item' , ( ) => {
199
- // TODO(crisbeto): this test fails without the NoopAnimationsModule for some reason.
200
- // It can indicate a deeper issue with the chips.
201
- const fixture = createComponent ( StandardChipGrid , undefined , [ NoopAnimationsModule ] ) ;
199
+ const fixture = createComponent ( StandardChipGrid ) ;
200
+ const lastAction = primaryActions [ primaryActions . length - 1 ] ;
201
+
202
202
// Focus the last item
203
- chips . last . focus ( ) ;
203
+ patchElementFocus ( lastAction ) ;
204
+ lastAction . focus ( ) ;
205
+ fixture . changeDetectorRef . markForCheck ( ) ;
206
+ fixture . detectChanges ( ) ;
204
207
205
208
// Destroy the last item
206
209
testComponent . chips . pop ( ) ;
@@ -212,9 +215,7 @@ describe('MatChipGrid', () => {
212
215
} ) ;
213
216
214
217
it ( 'should not focus if chip grid is not focused' , fakeAsync ( ( ) => {
215
- // TODO(crisbeto): this test fails without the NoopAnimationsModule for some reason.
216
- // It can indicate a deeper issue with the chips.
217
- const fixture = createComponent ( StandardChipGrid , undefined , [ NoopAnimationsModule ] ) ;
218
+ const fixture = createComponent ( StandardChipGrid ) ;
218
219
const midItem = chips . get ( 2 ) ! ;
219
220
220
221
// Focus and blur the middle item
@@ -233,9 +234,7 @@ describe('MatChipGrid', () => {
233
234
} ) ) ;
234
235
235
236
it ( 'should focus the grid if the last focused item is removed' , ( ) => {
236
- // TODO(crisbeto): this test fails without the NoopAnimationsModule for some reason.
237
- // It can indicate a deeper issue with the chips.
238
- const fixture = createComponent ( StandardChipGrid , undefined , [ NoopAnimationsModule ] ) ;
237
+ const fixture = createComponent ( StandardChipGrid ) ;
239
238
testComponent . chips = [ 0 ] ;
240
239
fixture . changeDetectorRef . markForCheck ( ) ;
241
240
@@ -252,7 +251,7 @@ describe('MatChipGrid', () => {
252
251
} ) ;
253
252
254
253
it ( 'should have a focus indicator' , ( ) => {
255
- createComponent ( StandardChipGrid , undefined , [ NoopAnimationsModule ] ) ;
254
+ createComponent ( StandardChipGrid ) ;
256
255
const focusIndicators = chipGridNativeElement . querySelectorAll (
257
256
'.mat-mdc-chip-primary-focus-indicator' ,
258
257
) ;
@@ -510,9 +509,7 @@ describe('MatChipGrid', () => {
510
509
describe ( 'FormFieldChipGrid' , ( ) => {
511
510
describe ( 'keyboard behavior' , ( ) => {
512
511
it ( 'should maintain focus if the active chip is deleted' , ( ) => {
513
- // TODO(crisbeto): this test fails without the NoopAnimationsModule for some reason.
514
- // It can indicate a deeper issue with the chips.
515
- const fixture = createComponent ( FormFieldChipGrid , undefined , [ NoopAnimationsModule ] ) ;
512
+ const fixture = createComponent ( FormFieldChipGrid ) ;
516
513
const secondChip = fixture . nativeElement . querySelectorAll ( '.mat-mdc-chip' ) [ 1 ] ;
517
514
const secondChipAction = secondChip . querySelector ( '.mdc-evolution-chip__action--primary' ) ;
518
515
@@ -658,9 +655,7 @@ describe('MatChipGrid', () => {
658
655
659
656
describe ( 'with chip remove' , ( ) => {
660
657
it ( 'should properly focus next item if chip is removed through click' , fakeAsync ( ( ) => {
661
- // TODO(crisbeto): this test fails without the NoopAnimationsModule for some reason.
662
- // It can indicate a deeper issue with the chips.
663
- const fixture = createComponent ( ChipGridWithRemove , undefined , [ NoopAnimationsModule ] ) ;
658
+ const fixture = createComponent ( ChipGridWithRemove ) ;
664
659
flush ( ) ;
665
660
const trailingActions = chipGridNativeElement . querySelectorAll < HTMLElement > (
666
661
'.mdc-evolution-chip__action--secondary' ,
0 commit comments