Skip to content

Instantly share code, notes, and snippets.

@maximilianschmitt
Last active August 29, 2015 14:10
Show Gist options
  • Save maximilianschmitt/668f18a11de4c0912b5a to your computer and use it in GitHub Desktop.
Save maximilianschmitt/668f18a11de4c0912b5a to your computer and use it in GitHub Desktop.
socket.io Mock
'use strict';
var EventEmitter = require('events').EventEmitter;
var mockSocket = function() {
return {
toServer: new EventEmitter(),
toClient: new EventEmitter(),
disconnect: function() {
this.toServer.emit('disconnect');
},
emit: function() {
this.toClient.emit.apply(this.toClient, arguments);
},
on: function() {
this.toServer.on.apply(this.toServer, arguments);
},
off: function() {
this.toServer.off.apply(this.toServer, arguments);
}
};
};
module.exports = mockSocket;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment