Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb4044f

Browse files
hoebbelsBedbzn
authored andcommitted
test(cdk): fix queueScheduler spec
1 parent 0331538 commit cb4044f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libs/cdk/zone-less/rxjs/spec/scheduler/queueScheduler.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { queueScheduler } from '@rx-angular/cdk/zone-less/rxjs';
22
import { Subscription, merge } from 'rxjs';
33
import { delay } from 'rxjs/operators';
4+
import { intervalProvider } from '../../src/internals/intervalProvider';
45
import { RxTestScheduler } from '../../src/testing/test-scheduler';
56
import { jestMatcher } from '@test-helpers';
67

@@ -12,10 +13,9 @@ describe('Scheduler.queue', () => {
1213

1314
beforeEach(() => {
1415
testScheduler = new RxTestScheduler(jestMatcher);
15-
});
16-
17-
afterEach(() => {
16+
jest.clearAllTimers();
1817
jest.useRealTimers();
18+
jest.clearAllMocks();
1919
});
2020

2121
it('should act like the async scheduler if delay > 0', () => {
@@ -33,6 +33,10 @@ describe('Scheduler.queue', () => {
3333

3434
it('should switch from synchronous to asynchronous at will', () => {
3535
jest.useFakeTimers();
36+
intervalProvider.delegate = {
37+
setInterval: setInterval,
38+
clearInterval: clearInterval,
39+
};
3640

3741
let asyncExec = false;
3842
const state: Array<number> = [];
@@ -58,6 +62,7 @@ describe('Scheduler.queue', () => {
5862

5963
expect(asyncExec).toBe(true);
6064
expect(state).toEqual([0, 1, 2]);
65+
intervalProvider.delegate = undefined;
6166
});
6267

6368
it('should unsubscribe the rest of the scheduled actions if an action throws an error', () => {

0 commit comments

Comments
 (0)