@@ -31,33 +31,54 @@ describe('Chip Remove', () => {
3131
3232 describe ( 'basic behavior' , ( ) => {
3333 it ( 'should applies the `mat-chip-remove` CSS class' , ( ) => {
34- let hrefElement = chipNativeElement . querySelector ( 'a ' ) ! ;
34+ let buttonElement = chipNativeElement . querySelector ( 'button ' ) ! ;
3535
36- expect ( hrefElement . classList ) . toContain ( 'mat-chip-remove' ) ;
36+ expect ( buttonElement . classList ) . toContain ( 'mat-chip-remove' ) ;
3737 } ) ;
3838
3939 it ( 'should emits (removed) on click' , ( ) => {
40- let hrefElement = chipNativeElement . querySelector ( 'a ' ) ! ;
40+ let buttonElement = chipNativeElement . querySelector ( 'button ' ) ! ;
4141
4242 testChip . removable = true ;
4343 fixture . detectChanges ( ) ;
4444
4545 spyOn ( testChip , 'didRemove' ) ;
4646
47- hrefElement . click ( ) ;
47+ buttonElement . click ( ) ;
48+ fixture . detectChanges ( ) ;
4849
4950 expect ( testChip . didRemove ) . toHaveBeenCalled ( ) ;
5051 } ) ;
52+
53+ it ( 'should not remove if parent chip is disabled' , ( ) => {
54+ let buttonElement = chipNativeElement . querySelector ( 'button' ) ! ;
55+
56+ testChip . disabled = true ;
57+ testChip . removable = true ;
58+ fixture . detectChanges ( ) ;
59+
60+ spyOn ( testChip , 'didRemove' ) ;
61+
62+ buttonElement . click ( ) ;
63+ fixture . detectChanges ( ) ;
64+
65+ expect ( testChip . didRemove ) . not . toHaveBeenCalled ( ) ;
66+ } ) ;
67+
5168 } ) ;
5269} ) ;
5370
5471@Component ( {
5572 template : `
56- <mat-chip [removable]="removable" (removed)="didRemove()"><a matChipRemove></a></mat-chip>
73+ <mat-chip
74+ [removable]="removable"
75+ [disabled]="disabled"
76+ (removed)="didRemove()"><button matChipRemove></button></mat-chip>
5777 `
5878} )
5979class TestChip {
6080 removable : boolean ;
81+ disabled = false ;
6182
6283 didRemove ( ) { }
6384}
0 commit comments