@@ -436,6 +436,43 @@ describe('Row Chips', () => {
436
436
} ) ) ;
437
437
} ) ;
438
438
439
+ describe ( '_hasInteractiveActions' , ( ) => {
440
+ it ( 'should return true if the chip has a remove icon' , ( ) => {
441
+ testComponent . removable = true ;
442
+ fixture . changeDetectorRef . markForCheck ( ) ;
443
+ fixture . detectChanges ( ) ;
444
+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( true ) ;
445
+ } ) ;
446
+
447
+ it ( 'should return true if the chip has an edit icon' , ( ) => {
448
+ testComponent . editable = true ;
449
+ testComponent . showEditIcon = true ;
450
+ fixture . changeDetectorRef . markForCheck ( ) ;
451
+ fixture . detectChanges ( ) ;
452
+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( true ) ;
453
+ } ) ;
454
+
455
+ it ( 'should return true even with a non-interactive trailing icon' , ( ) => {
456
+ testComponent . showTrailingIcon = true ;
457
+ fixture . changeDetectorRef . markForCheck ( ) ;
458
+ fixture . detectChanges ( ) ;
459
+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( true ) ;
460
+ } ) ;
461
+
462
+ it ( 'should return false if all actions are non-interactive' , ( ) => {
463
+ // Make primary action non-interactive for testing purposes.
464
+ chipInstance . primaryAction . isInteractive = false ;
465
+ testComponent . showTrailingIcon = true ;
466
+ testComponent . removable = false ; // remove icon is interactive
467
+ fixture . changeDetectorRef . markForCheck ( ) ;
468
+ fixture . detectChanges ( ) ;
469
+
470
+ // The trailing icon is not interactive.
471
+ expect ( chipInstance . trailingIcon . isInteractive ) . toBe ( false ) ;
472
+ expect ( chipInstance . _hasInteractiveActions ( ) ) . toBe ( false ) ;
473
+ } ) ;
474
+ } ) ;
475
+
439
476
describe ( 'with edit icon' , ( ) => {
440
477
beforeEach ( async ( ) => {
441
478
testComponent . showEditIcon = true ;
@@ -507,10 +544,15 @@ describe('Row Chips', () => {
507
544
<button matChipEdit>edit</button>
508
545
}
509
546
{{name}}
510
- <button matChipRemove>x</button>
547
+ @if (removable) {
548
+ <button matChipRemove>x</button>
549
+ }
511
550
@if (useCustomEditInput) {
512
551
<span class="projected-edit-input" matChipEditInput></span>
513
552
}
553
+ @if (showTrailingIcon) {
554
+ <span matChipTrailingIcon>trailing</span>
555
+ }
514
556
</mat-chip-row>
515
557
<input matInput [matChipInputFor]="chipGrid" #chipInput>
516
558
</div>
@@ -529,6 +571,7 @@ class SingleChip {
529
571
editable : boolean = false ;
530
572
showEditIcon : boolean = false ;
531
573
useCustomEditInput : boolean = true ;
574
+ showTrailingIcon = false ;
532
575
ariaLabel : string | null = null ;
533
576
ariaDescription : string | null = null ;
534
577
0 commit comments