Skip to content

Commit

Permalink
tests: add test for cookie-sessions example
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Mar 17, 2015
1 parent 279c8bb commit 389ab1b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/acceptance/cookie-sessions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

var app = require('../../examples/cookie-sessions')
var request = require('supertest')

function getCookie(res) {
return res.headers['set-cookie'][0].split(';')[0]
}

describe('cookie-sessions', function () {
describe('GET /', function () {
it('should display no views', function (done) {
request(app)
.get('/')
.expect(200, 'viewed 0 times\n', done)
})

it('should set a session cookie', function (done) {
request(app)
.get('/')
.expect('Set-Cookie', /connect\.sess=/)
.expect(200, done)
})

it('should display 1 view on revisit', function (done) {
request(app)
.get('/')
.expect(200, 'viewed 0 times\n', function (err, res) {
if (err) return done(err)
request(app)
.get('/')
.set('Cookie', getCookie(res))
.expect(200, 'viewed 1 times\n', done)
})
})
})
})

0 comments on commit 389ab1b

Please sign in to comment.