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 @@ -3,7 +3,7 @@ import {Component, DebugElement} from '@angular/core';
33import { By } from '@angular/platform-browser' ;
44import { ViewportRuler } from '@angular/cdk/scrolling' ;
55import { FakeViewportRuler } from '@angular/cdk/testing' ;
6- import { MatButtonModule } from './index' ;
6+ import { MatButtonModule , MatButton } from './index' ;
77import { MatRipple } from '@angular/material/core' ;
88
99
@@ -46,6 +46,13 @@ describe('MatButton', () => {
4646 expect ( aDebugElement . nativeElement . classList ) . not . toContain ( 'mat-accent' ) ;
4747 } ) ;
4848
49+ it ( 'should expose the ripple instance' , ( ) => {
50+ const fixture = TestBed . createComponent ( TestApp ) ;
51+ const button = fixture . debugElement . query ( By . css ( 'button' ) ) . componentInstance as MatButton ;
52+
53+ expect ( button . ripple ) . toBeTruthy ( ) ;
54+ } ) ;
55+
4956 it ( 'should should not clear previous defined classes' , ( ) => {
5057 let fixture = TestBed . createComponent ( TestApp ) ;
5158 let testComponent = fixture . debugElement . componentInstance ;
Original file line number Diff line number Diff line change @@ -18,12 +18,14 @@ import {
1818 OnDestroy ,
1919 Optional ,
2020 Self ,
21+ ViewChild ,
2122 ViewEncapsulation ,
2223} from '@angular/core' ;
2324import {
2425 CanColor ,
2526 CanDisable ,
2627 CanDisableRipple ,
28+ MatRipple ,
2729 mixinColor ,
2830 mixinDisabled ,
2931 mixinDisableRipple
@@ -135,6 +137,9 @@ export class MatButton extends _MatButtonMixinBase
135137 /** Whether the button is icon button. */
136138 _isIconButton : boolean = this . _hasHostAttributes ( 'mat-icon-button' ) ;
137139
140+ /** Reference to the MatRipple instance of the button. */
141+ @ViewChild ( MatRipple ) ripple : MatRipple ;
142+
138143 constructor ( elementRef : ElementRef ,
139144 private _platform : Platform ,
140145 private _focusMonitor : FocusMonitor ) {
You can’t perform that action at this time.
0 commit comments