diff --git a/spec/operators/publish-spec.js b/spec/operators/publish-spec.js index 4564583f3d..e4e8a0a42b 100644 --- a/spec/operators/publish-spec.js +++ b/spec/operators/publish-spec.js @@ -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); @@ -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(); - }); }); \ No newline at end of file diff --git a/spec/operators/publishBehavior-spec.js b/spec/operators/publishBehavior-spec.js index a93d17d8c0..85f5bf493a 100644 --- a/spec/operators/publishBehavior-spec.js +++ b/spec/operators/publishBehavior-spec.js @@ -1,4 +1,4 @@ -/* globals describe, it, expect */ +/* globals describe, it, expect, expectObservable, expectSubscriptions */ var Rx = require('../../dist/cjs/Rx'); var Observable = Rx.Observable; @@ -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); @@ -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(); - }); }); \ No newline at end of file