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 {}
43
43
44
44
export interface ChipSetHarnessFilters extends BaseHarnessFilters { }
45
45
46
+ export interface ChipEditHarnessFilters extends BaseHarnessFilters { }
47
+
46
48
export interface ChipRemoveHarnessFilters extends BaseHarnessFilters { }
47
49
48
50
export interface ChipAvatarHarnessFilters extends BaseHarnessFilters { }
Original file line number Diff line number Diff line change @@ -15,9 +15,11 @@ import {
15
15
import { MatChipAvatarHarness } from './chip-avatar-harness' ;
16
16
import {
17
17
ChipAvatarHarnessFilters ,
18
+ ChipEditHarnessFilters ,
18
19
ChipHarnessFilters ,
19
20
ChipRemoveHarnessFilters ,
20
21
} from './chip-harness-filters' ;
22
+ import { MatChipEditHarness } from './chip-edit-harness' ;
21
23
import { MatChipRemoveHarness } from './chip-remove-harness' ;
22
24
23
25
/** Harness for interacting with a mat-chip in tests. */
@@ -62,6 +64,14 @@ export class MatChipHarness extends ContentContainerComponentHarness {
62
64
await hostEl . sendKeys ( TestKey . DELETE ) ;
63
65
}
64
66
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
+
65
75
/**
66
76
* Gets the remove button inside of a chip.
67
77
* @param filter Optionally filters which chips are included.
You can’t perform that action at this time.
0 commit comments