Skip to content

Commit

Permalink
test: add failing test with schedulers
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Aug 1, 2020
1 parent 50f8dd9 commit 36a32a3
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions spec/schedulers/TestScheduler-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { expect } from 'chai';
import { hot, cold, expectObservable, expectSubscriptions, time } from '../helpers/marble-testing';
import { AsyncScheduler } from 'rxjs/internal/scheduler/AsyncScheduler';
import { TestScheduler } from 'rxjs/testing';
import { Observable, NEVER, EMPTY, Subject, of, merge } from 'rxjs';
import { delay, debounceTime, concatMap } from 'rxjs/operators';
import { Observable, NEVER, EMPTY, Subject, of, merge, animationFrameScheduler, asapScheduler, asyncScheduler } from 'rxjs';
import { delay, debounceTime, concatMap, mergeMap } from 'rxjs/operators';
import { nextNotification, COMPLETE_NOTIFICATION, errorNotification } from 'rxjs/internal/Notification';
import { animationFrameProvider } from 'rxjs/internal/scheduler/animationFrameProvider';
import { immediateProvider } from 'rxjs/internal/scheduler/immediateProvider';
Expand Down Expand Up @@ -682,5 +682,24 @@ describe('TestScheduler', () => {
});
});
});

describe('schedulers', () => {
it('should support all schedulers within run()', () => {
const testScheduler = new TestScheduler(assertDeepEquals);
testScheduler.run(({ animate, cold, expectObservable, time }) => {
animate(' ---------x');
const mapped = cold('--m-------');
const tb = time(' -----| ');
const expected = ' --(dc)-b-a';
const result = mapped.pipe(mergeMap(() => merge(
of('a').pipe(delay(0, animationFrameScheduler)),
of('b').pipe(delay(tb, asyncScheduler)),
of('c').pipe(delay(0, asyncScheduler)),
of('d').pipe(delay(0, asapScheduler))
)));
expectObservable(result).toBe(expected);
});
});
});
});
});

0 comments on commit 36a32a3

Please sign in to comment.