Skip to content

Instantly share code, notes, and snippets.

@maximilianschmitt
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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