Skip to content

Commit 9bf54af

Browse files
committed
feat: socket.disconnect
Closes #45
1 parent cc28ee8 commit 9bf54af

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

mock/socket-io.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function createMockSocketObject () {
4040
this._listeners = {};
4141
}
4242
},
43+
disconnect: function () {}
4344
};
4445

4546
return socket;

socket.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ angular.module('btford.socket-io', []).
6666
return socket.removeAllListeners.apply(socket, arguments);
6767
},
6868

69+
disconnect: function (close) {
70+
return socket.disconnect(close);
71+
},
72+
6973
// when socket.on('someEvent', fn (data) { ... }),
7074
// call scope.$broadcast('someEvent', data)
7175
forward: function (events, scope) {

socket.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ describe('socketFactory', function () {
4747
});
4848

4949

50+
describe('#disconnect', function () {
51+
52+
it('should call the underlying socket.disconnect', function () {
53+
mockIoSocket.disconnect = spy;
54+
socket.disconnect();
55+
expect(spy).toHaveBeenCalled();
56+
});
57+
58+
});
59+
60+
5061
describe('#once', function () {
5162

5263
it('should apply asynchronously', function () {

0 commit comments

Comments
 (0)