Skip to content

Commit

Permalink
tests: add more tests of cookies example
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed May 21, 2014
1 parent 1944451 commit cf5de08
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions test/acceptance/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,56 @@ describe('cookies', function(){
done()
})
})

it('should respond to cookie', function(done){
request(app)
.post('/')
.send({ remember: 1 })
.expect(302, function(err, res){
if (err) return done(err)
request(app)
.get('/')
.set('Cookie', res.headers['set-cookie'][0])
.expect(200, /Remembered/, done)
})
})
})

describe('GET /forget', function(){
it('should clear cookie', function(done){
request(app)
.post('/')
.send({ remember: 1 })
.expect(302, function(err, res){
if (err) return done(err)
request(app)
.get('/forget')
.set('Cookie', res.headers['set-cookie'][0])
.expect('Set-Cookie', /remember=;/)
.expect(302, done)
})
})
})

describe('POST /', function(){
it('should set a cookie', function(done){
request(app)
.post('/')
.send({ remember: 1 })
.end(function(err, res){
.expect(302, function(err, res){
res.headers.should.have.property('set-cookie')
done()
})
})

it('should no set cookie w/o reminder', function(done){
request(app)
.post('/')
.send({})
.expect(302, function(err, res){
res.headers.should.not.have.property('set-cookie')
done()
})
})
})
})
})

0 comments on commit cf5de08

Please sign in to comment.