Skip to content

Instantly share code, notes, and snippets.

@dewe
Created October 25, 2014 18:40
Show Gist options
  • Save dewe/9d57faf7ae1cb84af941 to your computer and use it in GitHub Desktop.
Save dewe/9d57faf7ae1cb84af941 to your computer and use it in GitHub Desktop.
How to mock session data for socket.io 0.9.16 in express.io 1.1.13
var app = require('express.io')();
app.http().io();
app.listen(7076)
// override authorization checks, always true. This works even though app has begun listening.
app.io.set('authorization', function (handshake, accept) { accept(null, true); });
// register a new handler for the message handler under test. The can inject mock data into session.
var handler = app.io.router['get-discussions'];
app.io.router['get-discussions'] = function (request) {
// create a new session for the request
request.sessionStore.generate(request);
// add some data to the session
request.session.apikey = "1234567890"
// call the sut.
handler(request);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment