1 | import { Subject } from 'rxjs';
|
2 | import { rlFakeAsync, rlTick, flushMicrotasks, rlQueueRequest } from './fakeAsync';
|
3 |
|
4 | describe('rlFakeAsync', () => {
|
5 | it('should schedule an rxjs action', rlFakeAsync(() => {
|
6 | const testStream = new Subject<void>();
|
7 | const testSpy = sinon.spy();
|
8 | testStream.delay(1000).subscribe(() => testSpy());
|
9 | testStream.next(null);
|
10 |
|
11 | sinon.assert.notCalled(testSpy);
|
12 |
|
13 | rlTick(1000);
|
14 | flushMicrotasks();
|
15 |
|
16 | sinon.assert.calledOnce(testSpy);
|
17 | }));
|
18 |
|
19 | it('should throw an error if there are pending requests', () => {
|
20 | expect(rlFakeAsync(() => {
|
21 | rlQueueRequest({ pending: true });
|
22 | })).to.throw('There are still pending requests. Please be sure to flush all of your requests');
|
23 | });
|
24 |
|
25 | it('should run successfully if all requests in the queue are resolved', () => {
|
26 | rlFakeAsync(() => {
|
27 | rlQueueRequest({ pending: false });
|
28 | })();
|
29 | });
|
30 | });
|