Last active
December 15, 2015 04:50
-
-
Save realyze/5204836 to your computer and use it in GitHub Desktop.
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
var request = require('supertest'), | |
should = require('should'), | |
express = require('express'); | |
var sessionStore = new express.session.MemoryStore(); | |
var app = express() | |
var secret = 'aaaaaa' | |
var sessionID; | |
app.use(express.cookieParser(secret)); | |
app.use(express.session({ | |
key: 'express.sid' | |
, store: sessionStore | |
})); | |
app.post('/v1/sessions', function(req, res){ | |
req.session.authenticated = true; | |
res.send('ok') | |
sessionID = req.sessionID; | |
}); | |
describe('Functional Test <Sessions>:', function () { | |
it('should create user session for valid user', function (done) { | |
request(app) | |
.post('/v1/sessions') | |
.set('Accept','application/json') | |
.send({"email": "[email protected]", "password": "123"}) | |
.end(function (err, res) { | |
sessionID.should.exist; | |
sessionStore.load(sessionID, function(err, session) { | |
if (err) { | |
return done(err); | |
} | |
session.authenticated.should.be.true; | |
done() | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment