File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
22import { Component , DebugElement } from '@angular/core' ;
33import { By } from '@angular/platform-browser' ;
4- import { MatButtonModule } from './index' ;
4+ import { MatButtonModule , MatButton } from './index' ;
55import { MatRipple } from '@angular/material/core' ;
66
77
@@ -41,6 +41,13 @@ describe('MatButton', () => {
4141 expect ( aDebugElement . nativeElement . classList ) . not . toContain ( 'mat-accent' ) ;
4242 } ) ;
4343
44+ it ( 'should expose the ripple instance' , ( ) => {
45+ const fixture = TestBed . createComponent ( TestApp ) ;
46+ const button = fixture . debugElement . query ( By . css ( 'button' ) ) . componentInstance as MatButton ;
47+
48+ expect ( button . ripple ) . toBeTruthy ( ) ;
49+ } ) ;
50+
4451 it ( 'should should not clear previous defined classes' , ( ) => {
4552 let fixture = TestBed . createComponent ( TestApp ) ;
4653 let testComponent = fixture . debugElement . componentInstance ;
Original file line number Diff line number Diff line change @@ -14,12 +14,14 @@ import {
1414 Directive ,
1515 ElementRef ,
1616 OnDestroy ,
17+ ViewChild ,
1718 ViewEncapsulation ,
1819} from '@angular/core' ;
1920import {
2021 CanColor ,
2122 CanDisable ,
2223 CanDisableRipple ,
24+ MatRipple ,
2325 mixinColor ,
2426 mixinDisabled ,
2527 mixinDisableRipple
@@ -118,6 +120,9 @@ export class MatButton extends _MatButtonMixinBase
118120 /** Whether the button is icon button. */
119121 _isIconButton : boolean = this . _hasHostAttributes ( 'mat-icon-button' ) ;
120122
123+ /** Reference to the MatRipple instance of the button. */
124+ @ViewChild ( MatRipple ) ripple : MatRipple ;
125+
121126 constructor ( elementRef : ElementRef ,
122127 private _platform : Platform ,
123128 private _focusMonitor : FocusMonitor ) {
You can’t perform that action at this time.
0 commit comments