Skip to content

Commit

Permalink
test(testSchedulerUi): do not convert synchronous test to async test
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jan 1, 2017
1 parent 6922b16 commit 6830ae3
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 260 deletions.
7 changes: 7 additions & 0 deletions spec/Observable-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {expect} from 'chai';
import * as sinon from 'sinon';
import * as Rx from '../dist/cjs/Rx';
import {TeardownLogic} from '../dist/cjs/Subscription';

Expand Down Expand Up @@ -211,6 +212,9 @@ describe('Observable', () => {
});

it('should run unsubscription logic when an error is sent asynchronously and subscribe is called with no arguments', (done: MochaDone) => {
const sandbox = sinon.sandbox.create();
const fakeTimer = sandbox.useFakeTimers();

let unsubscribeCalled = false;
const source = new Observable((subscriber: Rx.Subscriber<string>) => {
const id = setInterval(() => {
Expand Down Expand Up @@ -244,6 +248,9 @@ describe('Observable', () => {
}
}
}, 100);

fakeTimer.tick(110);
sandbox.restore();
});

it('should return a Subscription that calls the unsubscribe function returned by the subscriber', () => {
Expand Down
3 changes: 1 addition & 2 deletions spec/helpers/testScheduler-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports = function(suite) {
let modified = fn;

if (fn && fn.length === 0) {
modified = function (done: MochaDone) {
modified = function () {
context.rxTestScheduler = new Rx.TestScheduler(observableMatcher);
let error: Error = null;

Expand All @@ -166,7 +166,6 @@ module.exports = function(suite) {
error = e instanceof Error ? e : new Error(e);
} finally {
context.rxTestScheduler = null;
error ? done(error) : done();
}
};
}
Expand Down
3 changes: 1 addition & 2 deletions spec/subjects/BehaviorSubject-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ const ObjectUnsubscribedError = Rx.ObjectUnsubscribedError;

/** @test {BehaviorSubject} */
describe('BehaviorSubject', () => {
it('should extend Subject', (done: MochaDone) => {
it('should extend Subject', () => {
const subject = new BehaviorSubject(null);
expect(subject instanceof Rx.Subject).to.be.true;
done();
});

it('should throw if it has received an error and getValue() is called', () => {
Expand Down
Loading

0 comments on commit 6830ae3

Please sign in to comment.