Permalink
Browse files

fix signed cookies test

  • Loading branch information...
1 parent 9fb6615 commit 3b53b11fcd53efd5c96a8ca249b537276722f8b9 @tj tj committed Sep 16, 2013
Showing with 20 additions and 13 deletions.
  1. +20 −13 test/req.signedCookies.js
@@ -7,25 +7,32 @@ describe('req', function(){
it('should return a signed JSON cookie', function(done){
var app = express();
- var replacer = app.get('json replacer');
- var spaces = app.get('json spaces');
-
app.use(express.cookieParser('secret'));
app.use(function(req, res){
- res.send(req.signedCookies);
+ if ('/set' == req.path) {
+ res.cookie('obj', { foo: 'bar' }, { signed: true });
+ res.end();
+ } else {
+ res.send(req.signedCookies);
+ }
});
- app.response.req = { secret: 'secret' };
- app.response.cookie('obj', { foo: 'bar' }, { signed: true });
- var cookie = app.response.get('set-cookie').split(';')[0];
-
- var val = JSON.stringify({ obj: { foo: 'bar' } }, replacer, spaces);
-
request(app)
- .get('/')
- .set('Cookie', cookie)
- .expect(val, done);
+ .get('/set')
+ .end(function(err, res){
+ if (err) return done(err);
+ var cookie = res.header['set-cookie'];
+
+ request(app)
+ .get('/')
+ .set('Cookie', cookie)
+ .end(function(err, res){
+ if (err) return don(err);
+ res.body.should.eql({ obj: { foo: 'bar' } });
+ done();
+ });
+ });
})
it('should return a signed cookie', function(done){

0 comments on commit 3b53b11

Please sign in to comment.