Skip to content

Commit

Permalink
tests: add tests for overwrite option
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Feb 20, 2017
1 parent 5b66215 commit b8377b2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,43 @@ describe('Cookie Session', function () {
})
})

describe('"overwrite" option', function () {
it('should default to "true"', function (done) {
var app = App()
app.use(function (req, res, next) {
res.setHeader('Set-Cookie', [
'session=foo; path=/fake',
'foo=bar'
])
req.session.message = 'hi'
res.end(String(req.sessionOptions.overwrite))
})

request(app)
.get('/')
.expect('Set-Cookie', /foo=bar/)
.expect(200, 'true', done)
})

it('should use given "false"', function (done) {
var app = App({ overwrite: false })
app.use(function (req, res, next) {
res.setHeader('Set-Cookie', [
'session=foo; path=/fake',
'foo=bar'
])
req.session.message = 'hi'
res.end(String(req.sessionOptions.overwrite))
})

request(app)
.get('/')
.expect('Set-Cookie', /foo=bar/)
.expect('Set-Cookie', /session=foo/)
.expect(200, 'false', done)
})
})

describe('when options.name = my.session', function () {
it('should use my.session for cookie name', function (done) {
var app = App({ name: 'my.session' })
Expand Down

0 comments on commit b8377b2

Please sign in to comment.