File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
2
2
import { Component , DebugElement } from '@angular/core' ;
3
3
import { By } from '@angular/platform-browser' ;
4
- import { MatButtonModule } from './index' ;
4
+ import { MatButtonModule , MatButton } from './index' ;
5
5
import { MatRipple } from '@angular/material/core' ;
6
6
7
7
@@ -41,6 +41,13 @@ describe('MatButton', () => {
41
41
expect ( aDebugElement . nativeElement . classList ) . not . toContain ( 'mat-accent' ) ;
42
42
} ) ;
43
43
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
+
44
51
it ( 'should should not clear previous defined classes' , ( ) => {
45
52
let fixture = TestBed . createComponent ( TestApp ) ;
46
53
let testComponent = fixture . debugElement . componentInstance ;
Original file line number Diff line number Diff line change @@ -14,12 +14,14 @@ import {
14
14
Directive ,
15
15
ElementRef ,
16
16
OnDestroy ,
17
+ ViewChild ,
17
18
ViewEncapsulation ,
18
19
} from '@angular/core' ;
19
20
import {
20
21
CanColor ,
21
22
CanDisable ,
22
23
CanDisableRipple ,
24
+ MatRipple ,
23
25
mixinColor ,
24
26
mixinDisabled ,
25
27
mixinDisableRipple
@@ -118,6 +120,9 @@ export class MatButton extends _MatButtonMixinBase
118
120
/** Whether the button is icon button. */
119
121
_isIconButton : boolean = this . _hasHostAttributes ( 'mat-icon-button' ) ;
120
122
123
+ /** Reference to the MatRipple instance of the button. */
124
+ @ViewChild ( MatRipple ) ripple : MatRipple ;
125
+
121
126
constructor ( elementRef : ElementRef ,
122
127
private _platform : Platform ,
123
128
private _focusMonitor : FocusMonitor ) {
You can’t perform that action at this time.
0 commit comments