Skip to content

Commit

Permalink
refactor(test): reorder some test case to avoid unexpected jasmine be…
Browse files Browse the repository at this point in the history
…havior
  • Loading branch information
kwonoj committed Feb 10, 2016
1 parent ace3932 commit 835b9e9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
42 changes: 21 additions & 21 deletions spec/operators/publish-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ describe('Observable.prototype.publish()', function () {
published.connect();
});

it('To match RxJS 4 behavior, it should NOT allow you to reconnect by subscribing again', function (done) {
var expected = [1, 2, 3, 4];
var i = 0;

var source = Observable.of(1, 2, 3, 4).publish();

source.subscribe(function (x) {
expect(x).toBe(expected[i++]);
},
null,
function () {
source.subscribe(function (x) {
done.fail('should not be called');
}, null, done);

source.connect();
});

source.connect();
});

it('should return a ConnectableObservable', function () {
var source = Observable.of(1).publish();
expect(source instanceof Rx.ConnectableObservable).toBe(true);
Expand Down Expand Up @@ -300,25 +321,4 @@ describe('Observable.prototype.publish()', function () {
expect(subscriptions).toBe(1);
done();
});

it('To match RxJS 4 behavior, it should NOT allow you to reconnect by subscribing again', function (done) {
var expected = [1, 2, 3, 4];
var i = 0;

var source = Observable.of(1, 2, 3, 4).publish();

source.subscribe(function (x) {
expect(x).toBe(expected[i++]);
},
null,
function () {
source.subscribe(function (x) {
throw 'this should not be called';
}, null, done);

source.connect();
});

source.connect();
});
});
46 changes: 23 additions & 23 deletions spec/operators/publishBehavior-spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals describe, it, expect */
/* globals describe, it, expect, expectObservable, expectSubscriptions */
var Rx = require('../../dist/cjs/Rx');
var Observable = Rx.Observable;

Expand All @@ -15,6 +15,28 @@ describe('Observable.prototype.publishBehavior()', function () {
published.connect();
});

it('should follow the RxJS 4 behavior and NOT allow you to reconnect by subscribing again', function (done) {
var expected = [0, 1, 2, 3, 4];
var i = 0;

var source = Observable.of(1, 2, 3, 4).publishBehavior(0);

source.subscribe(
function (x) {
expect(x).toBe(expected[i++]);
},
null,
function () {
source.subscribe(function (x) {
done.fail('should not be called');
}, null, done);

source.connect();
});

source.connect();
});

it('should return a ConnectableObservable', function () {
var source = Observable.of(1).publishBehavior(1);
expect(source instanceof Rx.ConnectableObservable).toBe(true);
Expand Down Expand Up @@ -322,26 +344,4 @@ describe('Observable.prototype.publishBehavior()', function () {
expect(results).toEqual([]);
done();
});

it('should follow the RxJS 4 behavior and NOT allow you to reconnect by subscribing again', function (done) {
var expected = [0, 1, 2, 3, 4];
var i = 0;

var source = Observable.of(1, 2, 3, 4).publishBehavior(0);

source.subscribe(
function (x) {
expect(x).toBe(expected[i++]);
},
null,
function () {
source.subscribe(function (x) {
throw 'should not be called';
}, null, done);

source.connect();
});

source.connect();
});
});

0 comments on commit 835b9e9

Please sign in to comment.