@@ -436,6 +436,43 @@ 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.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+
439476 describe('with edit icon', () => {
440477 beforeEach(async () => {
441478 testComponent.showEditIcon = true;
@@ -507,10 +544,15 @@ describe('Row Chips', () => {
507544 <button matChipEdit>edit</button>
508545 }
509546 {{name}}
510- <button matChipRemove>x</button>
547+ @if (removable) {
548+ <button matChipRemove>x</button>
549+ }
511550 @if (useCustomEditInput) {
512551 <span class="projected-edit-input" matChipEditInput></span>
513552 }
553+ @if (showTrailingIcon) {
554+ <span matChipTrailingIcon>trailing</span>
555+ }
514556 </mat-chip-row>
515557 <input matInput [matChipInputFor]="chipGrid" #chipInput>
516558 </div>
@@ -529,6 +571,7 @@ class SingleChip {
529571 editable: boolean = false;
530572 showEditIcon: boolean = false;
531573 useCustomEditInput: boolean = true;
574+ showTrailingIcon = false;
532575 ariaLabel: string | null = null;
533576 ariaDescription: string | null = null;
534577
0 commit comments