WSConnection is not a singleton anymore

This commit is contained in:
Nicolas Le Goff
2014-02-27 14:25:10 +01:00
parent 5216e8fc9c
commit ef5b3fadb7
3 changed files with 59 additions and 75 deletions

View File

@@ -17,7 +17,7 @@ define([
this.session.subscribe = sinon.spy();
this.session.unsubscribe = sinon.spy();
this.wsConnection = connection.getInstance();
this.wsConnection = connection;
var $this = this;
var cbSuccess = function (session) {
$this.wsConnection.setSession($this.session);
@@ -29,6 +29,10 @@ define([
}
});
afterEach(function () {
this.wsConnection.close();
});
it("should have a session", function () {
this.wsConnection.connect();
assert.ok(this.wsConnection.hasSession());
@@ -48,12 +52,15 @@ define([
});
it("should not connect anymore after first connect", function () {
var throws = false;
this.wsConnection.connect();
ab.connect = sinon.spy();
this.wsConnection.connect();
this.wsConnection.connect();
this.wsConnection.connect();
expect(ab.connect.should.have.callCount(0)).to.be.ok;
try {
this.wsConnection.connect();
} catch (e) {
throws = true;
}
assert.ok(throws);
});
it("should call session subscribe once", function () {