Skip to content
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
6 changes: 5 additions & 1 deletion src/material/chips/testing/chip-harness-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import {BaseHarnessFilters} from '@angular/cdk/testing';
export interface ChipHarnessFilters extends BaseHarnessFilters {
/** Only find instances whose text matches the given value. */
text?: string | RegExp;
/** Only find chip instances whose selected state matches the given value. */
/**
* Only find chip instances whose selected state matches the given value.
* @deprecated Will be moved into separate selection-specific harness.
* @breaking-change 12.0.0
*/
selected?: boolean;
}

Expand Down
24 changes: 20 additions & 4 deletions src/material/chips/testing/chip-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export class MatChipHarness extends ComponentHarness {
});
}

/** Whether the chip is selected. */
/**
* Whether the chip is selected.
* @deprecated Will be moved into separate selection-specific harness.
* @breaking-change 12.0.0
*/
async isSelected(): Promise<boolean> {
return (await this.host()).hasClass('mat-chip-selected');
}
Expand All @@ -46,21 +50,33 @@ export class MatChipHarness extends ComponentHarness {
return (await this.host()).hasClass('mat-chip-disabled');
}

/** Selects the given chip. Only applies if it's selectable. */
/**
* Selects the given chip. Only applies if it's selectable.
* @deprecated Will be moved into separate selection-specific harness.
* @breaking-change 12.0.0
*/
async select(): Promise<void> {
if (!(await this.isSelected())) {
await this.toggle();
}
}

/** Deselects the given chip. Only applies if it's selectable. */
/**
* Deselects the given chip. Only applies if it's selectable.
* @deprecated Will be moved into separate selection-specific harness.
* @breaking-change 12.0.0
*/
async deselect(): Promise<void> {
if (await this.isSelected()) {
await this.toggle();
}
}

/** Toggles the selected state of the given chip. Only applies if it's selectable. */
/**
* Toggles the selected state of the given chip. Only applies if it's selectable.
* @deprecated Will be moved into separate selection-specific harness.
* @breaking-change 12.0.0
*/
async toggle(): Promise<void> {
return (await this.host()).sendKeys(' ');
}
Expand Down
2 changes: 2 additions & 0 deletions src/material/chips/testing/chip-list-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export class MatChipListHarness extends ComponentHarness {
* Selects a chip inside the chip list.
* @param filter An optional filter to apply to the child chips.
* All the chips matching the filter will be selected.
* @deprecated Will be moved into separate selection-specific harness.
* @breaking-change 12.0.0
*/
async selectChips(filter: ChipHarnessFilters = {}): Promise<void> {
const chips = await this.getChips(filter);
Expand Down