Skip to content

Commit 59891f0

Browse files
committed
tests
1 parent 14f412a commit 59891f0

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/material/chips/chip-row.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,21 @@ describe('Row Chips', () => {
351351
}));
352352
});
353353

354+
describe('with edit icon', () => {
355+
beforeEach(async () => {
356+
testComponent.showEditIcon = true;
357+
fixture.changeDetectorRef.markForCheck();
358+
fixture.detectChanges();
359+
});
360+
361+
it('should begin editing on edit click', () => {
362+
expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
363+
dispatchFakeEvent(chipNativeElement.querySelector('.mat-mdc-chip-edit')!, 'click');
364+
fixture.detectChanges();
365+
expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeTruthy();
366+
});
367+
});
368+
354369
describe('a11y', () => {
355370
it('should apply `ariaLabel` and `ariaDesciption` to the primary gridcell', () => {
356371
fixture.componentInstance.ariaLabel = 'chip name';
@@ -403,6 +418,9 @@ describe('Row Chips', () => {
403418
(destroyed)="chipDestroy($event)"
404419
(removed)="chipRemove($event)" (edited)="chipEdit($event)"
405420
[aria-label]="ariaLabel" [aria-description]="ariaDescription">
421+
@if (showEditIcon) {
422+
<button matChipEdit>edit</button>
423+
}
406424
{{name}}
407425
<button matChipRemove>x</button>
408426
@if (useCustomEditInput) {
@@ -424,6 +442,7 @@ class SingleChip {
424442
removable: boolean = true;
425443
shouldShow: boolean = true;
426444
editable: boolean = false;
445+
showEditIcon: boolean = false;
427446
useCustomEditInput: boolean = true;
428447
ariaLabel: string | null = null;
429448
ariaDescription: string | null = null;

src/material/chips/module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {MatChip} from './chip';
1313
import {MAT_CHIPS_DEFAULT_OPTIONS, MatChipsDefaultOptions} from './tokens';
1414
import {MatChipEditInput} from './chip-edit-input';
1515
import {MatChipGrid} from './chip-grid';
16-
import {MatChipAvatar, MatChipEdit, MatChipRemove, MatChipTrailingIcon} from './chip-icons';
16+
import {MatChipAvatar, MatChipRemove, MatChipTrailingIcon} from './chip-icons';
1717
import {MatChipInput} from './chip-input';
1818
import {MatChipListbox} from './chip-listbox';
1919
import {MatChipRow} from './chip-row';
@@ -24,7 +24,6 @@ import {MatChipAction} from './chip-action';
2424
const CHIP_DECLARATIONS = [
2525
MatChip,
2626
MatChipAvatar,
27-
MatChipEdit,
2827
MatChipEditInput,
2928
MatChipGrid,
3029
MatChipInput,

src/material/chips/testing/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
export * from './chip-avatar-harness';
10+
export * from './chip-edit-harness';
1011
export * from './chip-harness';
1112
export * from './chip-harness-filters';
1213
export * from './chip-input-harness';

0 commit comments

Comments
 (0)