File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
src/material/chips/testing Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright Google LLC All Rights Reserved.
4+ *
5+ * Use of this source code is governed by an MIT-style license that can be
6+ * found in the LICENSE file at https://angular.dev/license
7+ */
8+
9+ import {
10+ ComponentHarness ,
11+ ComponentHarnessConstructor ,
12+ HarnessPredicate ,
13+ } from '@angular/cdk/testing' ;
14+ import { ChipEditHarnessFilters } from './chip-harness-filters' ;
15+
16+ /** Harness for interacting with a standard Material chip edit button in tests. */
17+ export class MatChipEditHarness extends ComponentHarness {
18+ static hostSelector = '.mat-mdc-chip-edit' ;
19+
20+ /**
21+ * Gets a `HarnessPredicate` that can be used to search for a chip edit with specific
22+ * attributes.
23+ * @param options Options for filtering which input instances are considered a match.
24+ * @return a `HarnessPredicate` configured with the given options.
25+ */
26+ static with < T extends MatChipEditHarness > (
27+ this : ComponentHarnessConstructor < T > ,
28+ options : ChipEditHarnessFilters = { } ,
29+ ) : HarnessPredicate < T > {
30+ return new HarnessPredicate ( this , options ) ;
31+ }
32+
33+ /** Clicks the edit button. */
34+ async click ( ) : Promise < void > {
35+ return ( await this . host ( ) ) . click ( ) ;
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ export interface ChipRowHarnessFilters extends ChipHarnessFilters {}
4343
4444export interface ChipSetHarnessFilters extends BaseHarnessFilters { }
4545
46+ export interface ChipEditHarnessFilters extends BaseHarnessFilters { }
47+
4648export interface ChipRemoveHarnessFilters extends BaseHarnessFilters { }
4749
4850export interface ChipAvatarHarnessFilters extends BaseHarnessFilters { }
Original file line number Diff line number Diff line change @@ -15,9 +15,11 @@ import {
1515import { MatChipAvatarHarness } from './chip-avatar-harness' ;
1616import {
1717 ChipAvatarHarnessFilters ,
18+ ChipEditHarnessFilters ,
1819 ChipHarnessFilters ,
1920 ChipRemoveHarnessFilters ,
2021} from './chip-harness-filters' ;
22+ import { MatChipEditHarness } from './chip-edit-harness' ;
2123import { MatChipRemoveHarness } from './chip-remove-harness' ;
2224
2325/** Harness for interacting with a mat-chip in tests. */
@@ -62,6 +64,14 @@ export class MatChipHarness extends ContentContainerComponentHarness {
6264 await hostEl . sendKeys ( TestKey . DELETE ) ;
6365 }
6466
67+ /**
68+ * Gets the edit button inside of a chip.
69+ * @param filter Optionally filters which chips are included.
70+ */
71+ async geEditButton ( filter : ChipEditHarnessFilters = { } ) : Promise < MatChipEditHarness > {
72+ return this . locatorFor ( MatChipEditHarness . with ( filter ) ) ( ) ;
73+ }
74+
6575 /**
6676 * Gets the remove button inside of a chip.
6777 * @param filter Optionally filters which chips are included.
You can’t perform that action at this time.
0 commit comments