Skip to content

Commit

Permalink
fix(ajax): Use TestScheduler in timeout test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Bonnet committed May 10, 2018
1 parent 8bab826 commit 7766822
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spec/observables/dom/ajax-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { expect } from 'chai';
import * as sinon from 'sinon';
import * as Rx from 'rxjs/Rx';
import { root } from 'rxjs/util/root';
import { TestScheduler } from 'rxjs/testing';

declare const global: any;
declare const rxTestScheduler: TestScheduler;

/** @test {ajax} */
describe('Observable.ajax', () => {
Expand Down Expand Up @@ -380,7 +382,7 @@ describe('Observable.ajax', () => {
});
});

it('should error on timeout of asynchronous request', (done) => {
it('should error on timeout of asynchronous request', () => {
const obj: Rx.AjaxRequest = {
url: '/flibbertyJibbet',
responseType: 'text',
Expand All @@ -402,14 +404,15 @@ describe('Observable.ajax', () => {

expect(request.url).to.equal('/flibbertyJibbet');

setTimeout(() => {
rxTestScheduler.schedule(() => {
request.respondWith({
'status': 200,
'contentType': 'text/plain',
'responseText': 'Wee! I am text!'
});
done();
}, 1000);

rxTestScheduler.flush();
});

it('should create a synchronous request', () => {
Expand Down

0 comments on commit 7766822

Please sign in to comment.