|
1 | 1 | import {createMouseEvent, dispatchEvent} from '@angular/cdk/testing/private';
|
2 |
| -import {ApplicationRef, Component, DebugElement} from '@angular/core'; |
| 2 | +import {ApplicationRef, Component} from '@angular/core'; |
3 | 3 | import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
4 |
| -import {MatRipple, ThemePalette} from '@angular/material/core'; |
| 4 | +import {ThemePalette} from '@angular/material/core'; |
5 | 5 | import {By} from '@angular/platform-browser';
|
6 | 6 | import {
|
7 | 7 | MAT_BUTTON_CONFIG,
|
8 | 8 | MAT_FAB_DEFAULT_OPTIONS,
|
9 |
| - MatButton, |
10 | 9 | MatButtonModule,
|
11 | 10 | MatFabDefaultOptions,
|
12 | 11 | } from './index';
|
@@ -62,14 +61,6 @@ describe('MatButton', () => {
|
62 | 61 | expect(anchor.classList).toContain('mat-mdc-button-disabled');
|
63 | 62 | });
|
64 | 63 |
|
65 |
| - it('should expose the ripple instance', () => { |
66 |
| - const fixture = TestBed.createComponent(TestApp); |
67 |
| - fixture.detectChanges(); |
68 |
| - |
69 |
| - const button = fixture.debugElement.query(By.directive(MatButton))!.componentInstance; |
70 |
| - expect(button.ripple).toBeTruthy(); |
71 |
| - }); |
72 |
| - |
73 | 64 | it('should not clear previous defined classes', () => {
|
74 | 65 | let fixture = TestBed.createComponent(TestApp);
|
75 | 66 | let testComponent = fixture.debugElement.componentInstance;
|
@@ -287,86 +278,6 @@ describe('MatButton', () => {
|
287 | 278 | });
|
288 | 279 | });
|
289 | 280 |
|
290 |
| - // Ripple tests. |
291 |
| - describe('button ripples', () => { |
292 |
| - let fixture: ComponentFixture<TestApp>; |
293 |
| - let testComponent: TestApp; |
294 |
| - let buttonDebugElement: DebugElement; |
295 |
| - let buttonRippleInstance: MatRipple; |
296 |
| - let anchorDebugElement: DebugElement; |
297 |
| - let anchorRippleInstance: MatRipple; |
298 |
| - |
299 |
| - beforeEach(() => { |
300 |
| - fixture = TestBed.createComponent(TestApp); |
301 |
| - fixture.detectChanges(); |
302 |
| - |
303 |
| - testComponent = fixture.componentInstance; |
304 |
| - |
305 |
| - buttonDebugElement = fixture.debugElement.query(By.css('button[mat-button]'))!; |
306 |
| - buttonRippleInstance = buttonDebugElement.componentInstance.ripple; |
307 |
| - |
308 |
| - anchorDebugElement = fixture.debugElement.query(By.css('a[mat-button]'))!; |
309 |
| - anchorRippleInstance = anchorDebugElement.componentInstance.ripple; |
310 |
| - }); |
311 |
| - |
312 |
| - it('should disable the ripple if matRippleDisabled input is set', () => { |
313 |
| - expect(buttonRippleInstance.disabled).toBeFalsy(); |
314 |
| - |
315 |
| - testComponent.rippleDisabled = true; |
316 |
| - fixture.changeDetectorRef.markForCheck(); |
317 |
| - fixture.detectChanges(); |
318 |
| - |
319 |
| - expect(buttonRippleInstance.disabled).toBeTruthy(); |
320 |
| - }); |
321 |
| - |
322 |
| - it('should disable the ripple when the button is disabled', () => { |
323 |
| - expect(buttonRippleInstance.disabled).toBeFalsy( |
324 |
| - 'Expected an enabled button[mat-button] to have an enabled ripple', |
325 |
| - ); |
326 |
| - expect(anchorRippleInstance.disabled).toBeFalsy( |
327 |
| - 'Expected an enabled a[mat-button] to have an enabled ripple', |
328 |
| - ); |
329 |
| - |
330 |
| - testComponent.isDisabled = true; |
331 |
| - fixture.changeDetectorRef.markForCheck(); |
332 |
| - fixture.detectChanges(); |
333 |
| - |
334 |
| - expect(buttonRippleInstance.disabled).toBeTruthy( |
335 |
| - 'Expected a disabled button[mat-button] not to have an enabled ripple', |
336 |
| - ); |
337 |
| - expect(anchorRippleInstance.disabled).toBeTruthy( |
338 |
| - 'Expected a disabled a[mat-button] not to have an enabled ripple', |
339 |
| - ); |
340 |
| - }); |
341 |
| - |
342 |
| - it('should render the ripple once it is referenced', () => { |
343 |
| - const fab = fixture.debugElement.query(By.css('button[mat-fab]'))!; |
344 |
| - let ripple = fab.nativeElement.querySelector('.mat-mdc-button-ripple'); |
345 |
| - expect(ripple).withContext('Expect ripple to be absent before user interaction').toBeNull(); |
346 |
| - |
347 |
| - // Referencing the ripple should instantiate the ripple. |
348 |
| - expect(fab.componentInstance.ripple).toBeDefined(); |
349 |
| - |
350 |
| - ripple = fab.nativeElement.querySelector('.mat-mdc-button-ripple'); |
351 |
| - expect(ripple) |
352 |
| - .withContext('Expect ripple to be present after user interaction') |
353 |
| - .not.toBeNull(); |
354 |
| - }); |
355 |
| - |
356 |
| - // Ensure each of these events triggers the initialization of the button ripple. |
357 |
| - for (const event of ['mousedown', 'touchstart', 'mouseenter', 'focus']) { |
358 |
| - it(`should render the ripple once a button has received a "${event}" event`, () => { |
359 |
| - const fab = fixture.debugElement.query(By.css('button[mat-fab]'))!; |
360 |
| - let ripple = fab.nativeElement.querySelector('.mat-mdc-button-ripple'); |
361 |
| - expect(ripple).toBeNull(); |
362 |
| - |
363 |
| - dispatchEvent(fab.nativeElement, createMouseEvent(event)); |
364 |
| - ripple = fab.nativeElement.querySelector('.mat-mdc-button-ripple'); |
365 |
| - expect(ripple).not.toBeNull(); |
366 |
| - }); |
367 |
| - } |
368 |
| - }); |
369 |
| - |
370 | 281 | it('should have a focus indicator', () => {
|
371 | 282 | const fixture = TestBed.createComponent(TestApp);
|
372 | 283 | const buttonNativeElements = [
|
|
0 commit comments