mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
test(ripple): refactor long-running unit test (#2155)
Refactors a unit test that used to take 1.6s, due to it using a native `setTimeout`, by replacing the native timer with a flushable one. Fixes #2097.
This commit is contained in:
committed by
Jeremy Elbourn
parent
bac0388ca3
commit
b3e21b8aee
@@ -1,4 +1,4 @@
|
||||
import {TestBed, ComponentFixture, async} from '@angular/core/testing';
|
||||
import {TestBed, ComponentFixture, fakeAsync, tick} from '@angular/core/testing';
|
||||
import {Component, ViewChild} from '@angular/core';
|
||||
import {MdRipple, MdRippleModule} from './ripple';
|
||||
|
||||
@@ -132,14 +132,13 @@ describe('MdRipple', () => {
|
||||
expect(rippleElement.querySelectorAll('.md-ripple-foreground').length).toBe(0);
|
||||
});
|
||||
|
||||
it('removes foreground ripples after timeout', async(() => {
|
||||
it('removes foreground ripples after timeout', fakeAsync(() => {
|
||||
rippleElement.click();
|
||||
expect(rippleElement.querySelectorAll('.md-ripple-foreground').length).toBe(1);
|
||||
|
||||
// Use a real timeout because the ripple's timeout runs outside of the angular zone.
|
||||
setTimeout(() => {
|
||||
expect(rippleElement.querySelectorAll('.md-ripple-foreground').length).toBe(0);
|
||||
}, 1600);
|
||||
tick(1600);
|
||||
|
||||
expect(rippleElement.querySelectorAll('.md-ripple-foreground').length).toBe(0);
|
||||
}));
|
||||
|
||||
it('creates ripples when manually triggered', () => {
|
||||
|
||||
Reference in New Issue
Block a user