Skip to content

Commit ce79de7

Browse files
authored
docs: remove deprecated harness usage and use parallel promise utility (#21122)
* Uses `MatChipListboxHarness` for the chip harness example since `MatChipList` harness has some deprecated methods. * Uses `parallel` instead of `Promise.all` like we do in the test harness code.
1 parent 2465131 commit ce79de7

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/components-examples/material/card/card-harness/card-harness-example.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import {TestBed, ComponentFixture, waitForAsync} from '@angular/core/testing';
22
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
33
import {MatButtonHarness} from '@angular/material/button/testing';
44
import {MatCardHarness} from '@angular/material/card/testing';
5-
import {HarnessLoader} from '@angular/cdk/testing';
6-
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting}
7-
from '@angular/platform-browser-dynamic/testing';
5+
import {HarnessLoader, parallel} from '@angular/cdk/testing';
6+
import {
7+
BrowserDynamicTestingModule,
8+
platformBrowserDynamicTesting
9+
} from '@angular/platform-browser-dynamic/testing';
810
import {MatCardModule} from '@angular/material/card';
911
import {CardHarnessExample} from './card-harness-example';
1012

@@ -36,7 +38,7 @@ describe('CardHarnessExample', () => {
3638

3739
it('should get subtitle text', async () => {
3840
const cards = await loader.getAllHarnesses(MatCardHarness);
39-
expect(await Promise.all(cards.map(c => c.getSubtitleText()))).toEqual([
41+
expect(await parallel(() => cards.map(card => card.getSubtitleText()))).toEqual([
4042
'',
4143
'Dog Breed'
4244
]);

src/components-examples/material/chips/chips-harness/chips-harness-example.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {TestBed, ComponentFixture, waitForAsync} from '@angular/core/testing';
22
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';
79
import {ChipsHarnessExample} from './chips-harness-example';
810
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
911
import {MatChipsModule} from '@angular/material/chips';
@@ -27,7 +29,7 @@ describe('ChipsHarnessExample', () => {
2729
);
2830

2931
it('should get whether a chip list is disabled', async () => {
30-
const chipList = await loader.getHarness(MatChipListHarness);
32+
const chipList = await loader.getHarness(MatChipListboxHarness);
3133

3234
expect(await chipList.isDisabled()).toBeFalse();
3335

@@ -38,20 +40,20 @@ describe('ChipsHarnessExample', () => {
3840
});
3941

4042
it('should get the orientation of a chip list', async () => {
41-
const chipList = await loader.getHarness(MatChipListHarness);
43+
const chipList = await loader.getHarness(MatChipListboxHarness);
4244

4345
expect(await chipList.getOrientation()).toEqual('horizontal');
4446
});
4547

4648
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);
4850
const chips = await chipList.getChips();
4951

5052
expect((await chipList.getChips({selected: true})).length).toBe(0);
5153
await chips[1].select();
5254

5355
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']);
5557
});
5658

5759
it('should be able to trigger chip removal', async () => {

0 commit comments

Comments
 (0)