Skip to content

docs: remove deprecated harness usage and use parallel promise utility #21122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import {TestBed, ComponentFixture, waitForAsync} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatButtonHarness} from '@angular/material/button/testing';
import {MatCardHarness} from '@angular/material/card/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting}
from '@angular/platform-browser-dynamic/testing';
import {HarnessLoader, parallel} from '@angular/cdk/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
import {MatCardModule} from '@angular/material/card';
import {CardHarnessExample} from './card-harness-example';

Expand Down Expand Up @@ -36,7 +38,7 @@ describe('CardHarnessExample', () => {

it('should get subtitle text', async () => {
const cards = await loader.getAllHarnesses(MatCardHarness);
expect(await Promise.all(cards.map(c => c.getSubtitleText()))).toEqual([
expect(await parallel(() => cards.map(card => card.getSubtitleText()))).toEqual([
'',
'Dog Breed'
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {TestBed, ComponentFixture, waitForAsync} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatChipHarness, MatChipListHarness} from '@angular/material/chips/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting}
from '@angular/platform-browser-dynamic/testing';
import {MatChipHarness, MatChipListboxHarness} from '@angular/material/chips/testing';
import {HarnessLoader, parallel} from '@angular/cdk/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';
import {ChipsHarnessExample} from './chips-harness-example';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {MatChipsModule} from '@angular/material/chips';
Expand All @@ -27,7 +29,7 @@ describe('ChipsHarnessExample', () => {
);

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

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

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

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

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

it('should be able to get the selected chips in a list', async () => {
const chipList = await loader.getHarness(MatChipListHarness);
const chipList = await loader.getHarness(MatChipListboxHarness);
const chips = await chipList.getChips();

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

const selectedChips = await chipList.getChips({selected: true});
expect(await Promise.all(selectedChips.map(chip => chip.getText()))).toEqual(['Chip 2']);
expect(await parallel(() => selectedChips.map(chip => chip.getText()))).toEqual(['Chip 2']);
});

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