@@ -2,7 +2,7 @@ import {Directionality} from '@angular/cdk/bidi';
22import { createFakeEvent } from '@angular/cdk/testing/private' ;
33import { Component , DebugElement , ViewChild } from '@angular/core' ;
44import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
5- import { MAT_RIPPLE_GLOBAL_OPTIONS , RippleGlobalOptions } from '@angular/material/core' ;
5+ import { MatRipple } from '@angular/material/core' ;
66import { By } from '@angular/platform-browser' ;
77import { Subject } from 'rxjs' ;
88import { MatChip , MatChipEvent , MatChipSet , MatChipsModule } from './index' ;
@@ -13,12 +13,12 @@ describe('MDC-based MatChip', () => {
1313 let chipDebugElement : DebugElement ;
1414 let chipNativeElement : HTMLElement ;
1515 let chipInstance : MatChip ;
16- let globalRippleOptions : RippleGlobalOptions ;
16+ let chipRippleDebugElement : DebugElement ;
17+ let chipRippleInstance : MatRipple ;
1718
1819 let dir = 'ltr' ;
1920
2021 beforeEach ( async ( ( ) => {
21- globalRippleOptions = { } ;
2222 TestBed . configureTestingModule ( {
2323 imports : [ MatChipsModule ] ,
2424 declarations : [
@@ -28,7 +28,6 @@ describe('MDC-based MatChip', () => {
2828 BasicChipWithBoundTabindex ,
2929 ] ,
3030 providers : [
31- { provide : MAT_RIPPLE_GLOBAL_OPTIONS , useFactory : ( ) => globalRippleOptions } ,
3231 { provide : Directionality , useFactory : ( ) => ( {
3332 value : dir ,
3433 change : new Subject ( )
@@ -76,6 +75,15 @@ describe('MDC-based MatChip', () => {
7675
7776 expect ( chip . getAttribute ( 'tabindex' ) ) . toBe ( '15' ) ;
7877 } ) ;
78+
79+ it ( 'should have its ripple disabled' , ( ) => {
80+ fixture = TestBed . createComponent ( BasicChip ) ;
81+ fixture . detectChanges ( ) ;
82+ chipDebugElement = fixture . debugElement . query ( By . directive ( MatChip ) ) ! ;
83+ chipRippleDebugElement = chipDebugElement . query ( By . directive ( MatRipple ) ) ! ;
84+ chipRippleInstance = chipRippleDebugElement . injector . get < MatRipple > ( MatRipple ) ;
85+ expect ( chipRippleInstance . disabled ) . toBe ( true , 'Expected basic chip ripples to be disabled.' ) ;
86+ } ) ;
7987 } ) ;
8088
8189 describe ( 'MatChip' , ( ) => {
@@ -88,6 +96,8 @@ describe('MDC-based MatChip', () => {
8896 chipDebugElement = fixture . debugElement . query ( By . directive ( MatChip ) ) ! ;
8997 chipNativeElement = chipDebugElement . nativeElement ;
9098 chipInstance = chipDebugElement . injector . get < MatChip > ( MatChip ) ;
99+ chipRippleDebugElement = chipDebugElement . query ( By . directive ( MatRipple ) ) ! ;
100+ chipRippleInstance = chipRippleDebugElement . injector . get < MatRipple > ( MatRipple ) ;
91101 testComponent = fixture . debugElement . componentInstance ;
92102 } ) ;
93103
@@ -143,12 +153,22 @@ describe('MDC-based MatChip', () => {
143153 expect ( chipNativeElement . style . display ) . toBe ( 'none' ) ;
144154 } ) ;
145155
146- it ( 'should be able to disable ripples through ripple global options at runtime' , ( ) => {
147- expect ( chipInstance . rippleDisabled ) . toBe ( false , 'Expected chip ripples to be enabled.' ) ;
156+ it ( 'should be able to disable ripples with the `[rippleDisabled]` input' , ( ) => {
157+ expect ( chipRippleInstance . disabled ) . toBe ( false , 'Expected chip ripples to be enabled.' ) ;
158+
159+ testComponent . rippleDisabled = true ;
160+ fixture . detectChanges ( ) ;
161+
162+ expect ( chipRippleInstance . disabled ) . toBe ( true , 'Expected chip ripples to be disabled.' ) ;
163+ } ) ;
164+
165+ it ( 'should disable ripples when the chip is disabled' , ( ) => {
166+ expect ( chipRippleInstance . disabled ) . toBe ( false , 'Expected chip ripples to be enabled.' ) ;
148167
149- globalRippleOptions . disabled = true ;
168+ testComponent . disabled = true ;
169+ fixture . detectChanges ( ) ;
150170
151- expect ( chipInstance . rippleDisabled ) . toBe ( true , 'Expected chip ripples to be disabled.' ) ;
171+ expect ( chipRippleInstance . disabled ) . toBe ( true , 'Expected chip ripples to be disabled.' ) ;
152172 } ) ;
153173
154174 it ( 'should update the aria-label for disabled chips' , ( ) => {
@@ -191,7 +211,7 @@ describe('MDC-based MatChip', () => {
191211 <mat-chip [removable]="removable"
192212 [color]="color" [disabled]="disabled"
193213 (focus)="chipFocus($event)" (destroyed)="chipDestroy($event)"
194- (removed)="chipRemove($event)" [value]="value">
214+ (removed)="chipRemove($event)" [value]="value" [disableRipple]="rippleDisabled" >
195215 {{name}}
196216 </mat-chip>
197217 </div>
@@ -205,6 +225,7 @@ class SingleChip {
205225 removable : boolean = true ;
206226 shouldShow : boolean = true ;
207227 value : any ;
228+ rippleDisabled : boolean = false ;
208229
209230 chipFocus : ( event ?: MatChipEvent ) => void = ( ) => { } ;
210231 chipDestroy : ( event ?: MatChipEvent ) => void = ( ) => { } ;
0 commit comments