Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cdk/scrolling/scroll-dispatcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TestBed, fakeAsync, ComponentFixture, tick} from '@angular/core/testing';
import {TestBed, ComponentFixture} from '@angular/core/testing';
import {Component, ViewChild, ElementRef, ChangeDetectionStrategy} from '@angular/core';
import {CdkScrollable, ScrollDispatcher, ScrollingModule} from './public-api';
import {dispatchFakeEvent} from '../testing/private';
Expand Down Expand Up @@ -31,7 +31,7 @@ describe('ScrollDispatcher', () => {
expect(scroll.scrollContainers.has(componentScrollable)).toBe(false);
});

it('should notify through the directive and service that a scroll event occurred', fakeAsync(() => {
it('should notify through the directive and service that a scroll event occurred', async () => {
// Listen for notifications from scroll directive
const scrollable = fixture.componentInstance.scrollable;
const directiveSpy = jasmine.createSpy('directive scroll callback');
Expand All @@ -55,9 +55,9 @@ describe('ScrollDispatcher', () => {
expect(serviceSpy).not.toHaveBeenCalled();

// After the throttle time, the notification should be sent.
tick(throttleTime);
await new Promise(resolve => setTimeout(resolve, throttleTime + 10));
expect(serviceSpy).toHaveBeenCalled();
}));
});

it('should be able to unsubscribe from the global scrollable', () => {
const spy = jasmine.createSpy('global scroll callback');
Expand Down
10 changes: 5 additions & 5 deletions src/cdk/scrolling/viewport-ruler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TestBed, fakeAsync, tick} from '@angular/core/testing';
import {TestBed} from '@angular/core/testing';
import {dispatchFakeEvent} from '../testing/private';
import {ViewportRuler} from './viewport-ruler';

Expand Down Expand Up @@ -109,17 +109,17 @@ describe('ViewportRuler', () => {
subscription.unsubscribe();
});

it('should be able to throttle the callback', fakeAsync(() => {
it('should be able to throttle the callback', async () => {
const spy = jasmine.createSpy('viewport changed spy');
const subscription = viewportRuler.change(1337).subscribe(spy);
const subscription = viewportRuler.change(10).subscribe(spy);

dispatchFakeEvent(window, 'resize');
expect(spy).not.toHaveBeenCalled();

tick(1337);
await new Promise(resolve => setTimeout(resolve, 20));

expect(spy).toHaveBeenCalledTimes(1);
subscription.unsubscribe();
}));
});
});
});
Loading
Loading