add tests for Socket service

This commit is contained in:
Matias Alejo Garcia 2014-06-04 20:17:45 -03:00
commit bfa5d4ac51
3 changed files with 36 additions and 2 deletions

View file

@ -9,6 +9,40 @@ describe("Unit: Testing Services", function() {
expect(Socket).not.to.equal(null);
}));
it('Socket should support #on', inject(function(Socket) {
expect(Socket.on).to.be.a('function');
}));
it('Socket should support #sysOn', inject(function(Socket) {
expect(Socket.sysOn).to.be.a('function');
}))
it('Socket should add handlers with #on', inject(function(Socket) {
Socket.on('a', function (){});
Socket.on('b', function (){});
Socket.sysOn('c', function (){});
var ret = Socket.getListeners();
expect(ret.a).to.be.equal(1);
expect(ret.b).to.be.equal(1);
expect(Object.keys(ret)).to.have.length(2);
}));
it('Socket should support #removeAllListeners', inject(function(Socket) {
Socket.on('a', function (){});
Socket.on('b', function (){});
Socket.sysOn('c', function (){});
var ret = Socket.getListeners();
expect(Object.keys(ret)).to.have.length(2);
Socket.removeAllListeners();
ret = Socket.getListeners();
expect(Object.keys(ret)).to.have.length(0);
}));
it('should contain a walletFactory service', inject(function(walletFactory) {
expect(walletFactory).not.to.equal(null);
}));