Last active
August 29, 2015 14:10
-
-
Save maximilianschmitt/668f18a11de4c0912b5a to your computer and use it in GitHub Desktop.
socket.io Mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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