@@ -2,6 +2,8 @@ import {HarnessLoader, parallel} from '@angular/cdk/testing';
22import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed' ;
33import { Component } from '@angular/core' ;
44import { ComponentFixture , TestBed } from '@angular/core/testing' ;
5+ import { MatIconModule } from '@angular/material/icon' ;
6+ import { MatIconHarness } from '@angular/material/icon/testing' ;
57import { MatChipsModule } from '../index' ;
68import { MatChipHarness } from './chip-harness' ;
79
@@ -12,7 +14,7 @@ describe('MatChipHarness', () => {
1214
1315 beforeEach ( async ( ) => {
1416 await TestBed . configureTestingModule ( {
15- imports : [ MatChipsModule ] ,
17+ imports : [ MatChipsModule , MatIconModule ] ,
1618 declarations : [ ChipHarnessTest ] ,
1719 } ) . compileComponents ( ) ;
1820
@@ -55,13 +57,35 @@ describe('MatChipHarness', () => {
5557 expect ( await harness . getRemoveButton ( ) ) . toBeTruthy ( ) ;
5658 } ) ;
5759
60+ it ( 'should find avatar in chip' , async ( ) => {
61+ const chip = await loader . getHarness ( MatChipHarness . with ( {
62+ selector : '.mat-mdc-chip-with-avatar'
63+ } ) ) ;
64+ const avatar = await chip . getAvatar ( ) ;
65+ expect ( avatar ) . toBeTruthy ( ) ;
66+ const avatarHost = await avatar ?. host ( ) ;
67+ expect ( await avatarHost ?. getAttribute ( 'aria-label' ) ) . toBe ( 'Coronavirus' ) ;
68+ } ) ;
69+
70+ it ( 'should find icon in chip' , async ( ) => {
71+ const chip = await loader . getHarness ( MatChipHarness . with ( {
72+ selector : '.mat-mdc-chip-with-icon-avatar'
73+ } ) ) ;
74+ expect ( chip ) . toBeTruthy ( ) ;
75+ const icon = await chip . getHarness ( MatIconHarness ) ;
76+ expect ( icon ) . toBeTruthy ( ) ;
77+ expect ( await icon . getName ( ) ) . toBe ( 'coronavirus' ) ;
78+ } ) ;
5879} ) ;
5980
6081@Component ( {
6182 template : `
6283 <mat-basic-chip>Basic Chip</mat-basic-chip>
6384 <mat-chip>Chip <span matChipTrailingIcon>trailing_icon</span></mat-chip>
64- <mat-chip><mat-chip-avatar>B</mat-chip-avatar>Chip with avatar</mat-chip>
85+ <mat-chip class="mat-mdc-chip-with-icon-avatar">
86+ <mat-icon matChipAvatar aria-label="Coronavirus" aria-hidden="false">coronavirus</mat-icon>
87+ Chip with avatar
88+ </mat-chip>
6589 <mat-chip
6690 class="has-remove-button"
6791 disabled>Disabled Chip <span matChipRemove>remove_icon</span>
0 commit comments