1
1
import { TestBed , ComponentFixture , waitForAsync } from '@angular/core/testing' ;
2
2
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed' ;
3
- import { MatChipHarness , MatChipListHarness } from '@angular/material/chips/testing' ;
4
- import { HarnessLoader } from '@angular/cdk/testing' ;
5
- import { BrowserDynamicTestingModule , platformBrowserDynamicTesting }
6
- from '@angular/platform-browser-dynamic/testing' ;
3
+ import { MatChipHarness , MatChipListboxHarness } from '@angular/material/chips/testing' ;
4
+ import { HarnessLoader , parallel } from '@angular/cdk/testing' ;
5
+ import {
6
+ BrowserDynamicTestingModule ,
7
+ platformBrowserDynamicTesting ,
8
+ } from '@angular/platform-browser-dynamic/testing' ;
7
9
import { ChipsHarnessExample } from './chips-harness-example' ;
8
10
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
9
11
import { MatChipsModule } from '@angular/material/chips' ;
@@ -27,7 +29,7 @@ describe('ChipsHarnessExample', () => {
27
29
) ;
28
30
29
31
it ( 'should get whether a chip list is disabled' , async ( ) => {
30
- const chipList = await loader . getHarness ( MatChipListHarness ) ;
32
+ const chipList = await loader . getHarness ( MatChipListboxHarness ) ;
31
33
32
34
expect ( await chipList . isDisabled ( ) ) . toBeFalse ( ) ;
33
35
@@ -38,20 +40,20 @@ describe('ChipsHarnessExample', () => {
38
40
} ) ;
39
41
40
42
it ( 'should get the orientation of a chip list' , async ( ) => {
41
- const chipList = await loader . getHarness ( MatChipListHarness ) ;
43
+ const chipList = await loader . getHarness ( MatChipListboxHarness ) ;
42
44
43
45
expect ( await chipList . getOrientation ( ) ) . toEqual ( 'horizontal' ) ;
44
46
} ) ;
45
47
46
48
it ( 'should be able to get the selected chips in a list' , async ( ) => {
47
- const chipList = await loader . getHarness ( MatChipListHarness ) ;
49
+ const chipList = await loader . getHarness ( MatChipListboxHarness ) ;
48
50
const chips = await chipList . getChips ( ) ;
49
51
50
52
expect ( ( await chipList . getChips ( { selected : true } ) ) . length ) . toBe ( 0 ) ;
51
53
await chips [ 1 ] . select ( ) ;
52
54
53
55
const selectedChips = await chipList . getChips ( { selected : true } ) ;
54
- expect ( await Promise . all ( selectedChips . map ( chip => chip . getText ( ) ) ) ) . toEqual ( [ 'Chip 2' ] ) ;
56
+ expect ( await parallel ( ( ) => selectedChips . map ( chip => chip . getText ( ) ) ) ) . toEqual ( [ 'Chip 2' ] ) ;
55
57
} ) ;
56
58
57
59
it ( 'should be able to trigger chip removal' , async ( ) => {
0 commit comments