@@ -436,6 +436,39 @@ describe('Row Chips', () => {
436436 } ) ) ;
437437 } ) ;
438438
439+ describe ( '_hasInteractiveActions' , ( ) => {
440+ it ( 'should return true if the chip has a remove icon' , ( ) => {
441+ testComponent . removable = true ;
442+ fixture . detectChanges ( ) ;
443+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( true ) ;
444+ } ) ;
445+
446+ it ( 'should return true if the chip has an edit icon' , ( ) => {
447+ testComponent . editable = true ;
448+ testComponent . showEditIcon = true ;
449+ fixture . detectChanges ( ) ;
450+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( true ) ;
451+ } ) ;
452+
453+ it ( 'should return true even with a non-interactive trailing icon' , ( ) => {
454+ testComponent . showTrailingIcon = true ;
455+ fixture . detectChanges ( ) ;
456+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( true ) ;
457+ } ) ;
458+
459+ it ( 'should return false if all actions are non-interactive' , ( ) => {
460+ // Make primary action non-interactive for testing purposes.
461+ chipInstance . primaryAction . isInteractive = false ;
462+ testComponent . showTrailingIcon = true ;
463+ testComponent . removable = false ; // remove icon is interactive
464+ fixture . detectChanges ( ) ;
465+
466+ // The trailing icon is not interactive.
467+ expect ( chipInstance . trailingIcon . isInteractive ) . toBe ( false ) ;
468+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( false ) ;
469+ } ) ;
470+ } ) ;
471+
439472 describe ( 'with edit icon' , ( ) => {
440473 beforeEach ( async ( ) => {
441474 testComponent . showEditIcon = true ;
@@ -507,10 +540,15 @@ describe('Row Chips', () => {
507540 <button matChipEdit>edit</button>
508541 }
509542 {{name}}
510- <button matChipRemove>x</button>
543+ @if (removable) {
544+ <button matChipRemove>x</button>
545+ }
511546 @if (useCustomEditInput) {
512547 <span class="projected-edit-input" matChipEditInput></span>
513548 }
549+ @if (showTrailingIcon) {
550+ <span matChipTrailingIcon>trailing</span>
551+ }
514552 </mat-chip-row>
515553 <input matInput [matChipInputFor]="chipGrid" #chipInput>
516554 </div>
@@ -529,6 +567,7 @@ class SingleChip {
529567 editable : boolean = false ;
530568 showEditIcon : boolean = false ;
531569 useCustomEditInput : boolean = true ;
570+ showTrailingIcon = false ;
532571 ariaLabel : string | null = null ;
533572 ariaDescription : string | null = null ;
534573
0 commit comments