Skip to content

Commit

Permalink
test(WebSocketSubject): add test for multiplex in combination with retry
Browse files Browse the repository at this point in the history
It works since 5.0.0.beta.8, but there is no test which ensures this for the future.

related ReactiveX#1466
  • Loading branch information
fs123 committed May 31, 2016
1 parent ceb9990 commit a7c136d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions spec/observables/dom/webSocket-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,5 +391,38 @@ describe('Observable.webSocket', () => {
expect(socket.close).have.been.called;
(<any>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(<any>{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;
});
});
});

0 comments on commit a7c136d

Please sign in to comment.