Skip to content

Commit fdf71ac

Browse files
crisbetojelbourn
authored andcommitted
refactor(material/chips): deprecate selection methods in test harnesses (#20817)
Deprecates the selection-related methods from the test harnesses. They'll be moved into a separate harness in order to make the migration to MDC easier. (cherry picked from commit f195036)
1 parent 6333b96 commit fdf71ac

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/material/chips/testing/chip-harness-filters.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import {BaseHarnessFilters} from '@angular/cdk/testing';
1111
export interface ChipHarnessFilters extends BaseHarnessFilters {
1212
/** Only find instances whose text matches the given value. */
1313
text?: string | RegExp;
14-
/** Only find chip instances whose selected state matches the given value. */
14+
/**
15+
* Only find chip instances whose selected state matches the given value.
16+
* @deprecated Will be moved into separate selection-specific harness.
17+
* @breaking-change 12.0.0
18+
*/
1519
selected?: boolean;
1620
}
1721

src/material/chips/testing/chip-harness.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export class MatChipHarness extends ComponentHarness {
3636
});
3737
}
3838

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

49-
/** Selects the given chip. Only applies if it's selectable. */
53+
/**
54+
* Selects the given chip. Only applies if it's selectable.
55+
* @deprecated Will be moved into separate selection-specific harness.
56+
* @breaking-change 12.0.0
57+
*/
5058
async select(): Promise<void> {
5159
if (!(await this.isSelected())) {
5260
await this.toggle();
5361
}
5462
}
5563

56-
/** Deselects the given chip. Only applies if it's selectable. */
64+
/**
65+
* Deselects the given chip. Only applies if it's selectable.
66+
* @deprecated Will be moved into separate selection-specific harness.
67+
* @breaking-change 12.0.0
68+
*/
5769
async deselect(): Promise<void> {
5870
if (await this.isSelected()) {
5971
await this.toggle();
6072
}
6173
}
6274

63-
/** Toggles the selected state of the given chip. Only applies if it's selectable. */
75+
/**
76+
* Toggles the selected state of the given chip. Only applies if it's selectable.
77+
* @deprecated Will be moved into separate selection-specific harness.
78+
* @breaking-change 12.0.0
79+
*/
6480
async toggle(): Promise<void> {
6581
return (await this.host()).sendKeys(' ');
6682
}

src/material/chips/testing/chip-list-harness.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export class MatChipListHarness extends ComponentHarness {
6868
* Selects a chip inside the chip list.
6969
* @param filter An optional filter to apply to the child chips.
7070
* All the chips matching the filter will be selected.
71+
* @deprecated Will be moved into separate selection-specific harness.
72+
* @breaking-change 12.0.0
7173
*/
7274
async selectChips(filter: ChipHarnessFilters = {}): Promise<void> {
7375
const chips = await this.getChips(filter);

0 commit comments

Comments
 (0)