From a7c136da4c6ea0318e08bbceffa8b30178f3c19b Mon Sep 17 00:00:00 2001 From: Flavio Date: Tue, 31 May 2016 23:45:27 +0200 Subject: [PATCH] test(WebSocketSubject): add test for multiplex in combination with retry It works since 5.0.0.beta.8, but there is no test which ensures this for the future. related #1466 --- spec/observables/dom/webSocket-spec.ts | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/spec/observables/dom/webSocket-spec.ts b/spec/observables/dom/webSocket-spec.ts index 0d7aac3589..137ea3b45c 100644 --- a/spec/observables/dom/webSocket-spec.ts +++ b/spec/observables/dom/webSocket-spec.ts @@ -391,5 +391,38 @@ describe('Observable.webSocket', () => { expect(socket.close).have.been.called; (socket.close).restore(); }); + + it('should work in combination with retry (issue #1466)', () => { + const error = { wasClean: false}; + + var subCounter = 0; + var unsubCounter = 0; + + const subject = Observable.webSocket({url: 'ws://mysocket'}) + .multiplex( + () => subCounter++, + () => unsubCounter++, + () => true) + .retry(1); + + var nextCalled = false; + var failed = null; + var completed = false; + subject.subscribe( + () => nextCalled = true, + (e) => failed = e, + () => completed = true); + + let socket = MockWebSocket.lastSocket; + + socket.triggerClose(error); + + expect(subCounter).to.equal(2); + expect(unsubCounter).to.equal(2); + + expect(nextCalled).to.be.false; + expect(failed).to.equal(error); + expect(completed).to.be.false; + }); }); }); \ No newline at end of file