Skip to content

Commit

Permalink
deps: cookie@0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Apr 12, 2022
1 parent 8880dda commit 92c5ce5
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
3 changes: 3 additions & 0 deletions History.md
Expand Up @@ -19,6 +19,9 @@ unreleased
- deps: on-finished@2.4.1
- deps: qs@6.10.3
- deps: raw-body@2.5.1
* deps: cookie@0.5.0
- Add `priority` option
- Fix `expires` option to reject invalid dates
* deps: depd@2.0.0
- Replace internal `eval` usage with `Function` constructor
- Use instance methods on `process` to check for listeners
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -33,7 +33,7 @@
"body-parser": "1.20.0",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.4.2",
"cookie": "0.5.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
Expand Down
72 changes: 72 additions & 0 deletions test/res.cookie.js
Expand Up @@ -67,6 +67,21 @@ describe('res', function(){
.expect(200, done)
})

describe('expires', function () {
it('should throw on invalid date', function (done) {
var app = express()

app.use(function (req, res) {
res.cookie('name', 'tobi', { expires: new Date(NaN) })
res.end()
})

request(app)
.get('/')
.expect(500, /option expires is invalid/, done)
})
})

describe('maxAge', function(){
it('should set relative expires', function(done){
var app = express();
Expand Down Expand Up @@ -155,6 +170,63 @@ describe('res', function(){
})
})

describe('priority', function () {
it('should set low priority', function (done) {
var app = express()

app.use(function (req, res) {
res.cookie('name', 'tobi', { priority: 'low' })
res.end()
})

request(app)
.get('/')
.expect('Set-Cookie', /Priority=Low/)
.expect(200, done)
})

it('should set medium priority', function (done) {
var app = express()

app.use(function (req, res) {
res.cookie('name', 'tobi', { priority: 'medium' })
res.end()
})

request(app)
.get('/')
.expect('Set-Cookie', /Priority=Medium/)
.expect(200, done)
})

it('should set high priority', function (done) {
var app = express()

app.use(function (req, res) {
res.cookie('name', 'tobi', { priority: 'high' })
res.end()
})

request(app)
.get('/')
.expect('Set-Cookie', /Priority=High/)
.expect(200, done)
})

it('should throw with invalid priority', function (done) {
var app = express()

app.use(function (req, res) {
res.cookie('name', 'tobi', { priority: 'foobar' })
res.end()
})

request(app)
.get('/')
.expect(500, /option priority is invalid/, done)
})
})

describe('signed', function(){
it('should generate a signed JSON cookie', function(done){
var app = express();
Expand Down

0 comments on commit 92c5ce5

Please sign in to comment.