Skip to content

Commit 92c5ce5

Browse files
committedApr 12, 2022
deps: cookie@0.5.0
1 parent 8880dda commit 92c5ce5

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed
 

‎History.md

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ unreleased
1919
- deps: on-finished@2.4.1
2020
- deps: qs@6.10.3
2121
- deps: raw-body@2.5.1
22+
* deps: cookie@0.5.0
23+
- Add `priority` option
24+
- Fix `expires` option to reject invalid dates
2225
* deps: depd@2.0.0
2326
- Replace internal `eval` usage with `Function` constructor
2427
- Use instance methods on `process` to check for listeners

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"body-parser": "1.20.0",
3434
"content-disposition": "0.5.4",
3535
"content-type": "~1.0.4",
36-
"cookie": "0.4.2",
36+
"cookie": "0.5.0",
3737
"cookie-signature": "1.0.6",
3838
"debug": "2.6.9",
3939
"depd": "2.0.0",

‎test/res.cookie.js

+72
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ describe('res', function(){
6767
.expect(200, done)
6868
})
6969

70+
describe('expires', function () {
71+
it('should throw on invalid date', function (done) {
72+
var app = express()
73+
74+
app.use(function (req, res) {
75+
res.cookie('name', 'tobi', { expires: new Date(NaN) })
76+
res.end()
77+
})
78+
79+
request(app)
80+
.get('/')
81+
.expect(500, /option expires is invalid/, done)
82+
})
83+
})
84+
7085
describe('maxAge', function(){
7186
it('should set relative expires', function(done){
7287
var app = express();
@@ -155,6 +170,63 @@ describe('res', function(){
155170
})
156171
})
157172

173+
describe('priority', function () {
174+
it('should set low priority', function (done) {
175+
var app = express()
176+
177+
app.use(function (req, res) {
178+
res.cookie('name', 'tobi', { priority: 'low' })
179+
res.end()
180+
})
181+
182+
request(app)
183+
.get('/')
184+
.expect('Set-Cookie', /Priority=Low/)
185+
.expect(200, done)
186+
})
187+
188+
it('should set medium priority', function (done) {
189+
var app = express()
190+
191+
app.use(function (req, res) {
192+
res.cookie('name', 'tobi', { priority: 'medium' })
193+
res.end()
194+
})
195+
196+
request(app)
197+
.get('/')
198+
.expect('Set-Cookie', /Priority=Medium/)
199+
.expect(200, done)
200+
})
201+
202+
it('should set high priority', function (done) {
203+
var app = express()
204+
205+
app.use(function (req, res) {
206+
res.cookie('name', 'tobi', { priority: 'high' })
207+
res.end()
208+
})
209+
210+
request(app)
211+
.get('/')
212+
.expect('Set-Cookie', /Priority=High/)
213+
.expect(200, done)
214+
})
215+
216+
it('should throw with invalid priority', function (done) {
217+
var app = express()
218+
219+
app.use(function (req, res) {
220+
res.cookie('name', 'tobi', { priority: 'foobar' })
221+
res.end()
222+
})
223+
224+
request(app)
225+
.get('/')
226+
.expect(500, /option priority is invalid/, done)
227+
})
228+
})
229+
158230
describe('signed', function(){
159231
it('should generate a signed JSON cookie', function(done){
160232
var app = express();

0 commit comments

Comments
 (0)
Please sign in to comment.