forked from expressjs/express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathres.clearCookie.js
62 lines (49 loc) · 1.57 KB
/
res.clearCookie.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'use strict'
var express = require('../')
, request = require('supertest');
describe('res', function(){
describe('.clearCookie(name)', function(){
it('should set a cookie passed expiry', function(done){
var app = express();
app.use(function(req, res){
res.clearCookie('sid').end();
});
request(app)
.get('/')
.expect('Set-Cookie', 'sid=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
.expect(200, done)
})
})
describe('.clearCookie(name, options)', function(){
it('should set the given params', function(done){
var app = express();
app.use(function(req, res){
res.clearCookie('sid', { path: '/admin' }).end();
});
request(app)
.get('/')
.expect('Set-Cookie', 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
.expect(200, done)
})
it('should ignore maxAge', function(done){
var app = express();
app.use(function(req, res){
res.clearCookie('sid', { path: '/admin', maxAge: 1000 }).end();
});
request(app)
.get('/')
.expect('Set-Cookie', 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
.expect(200, done)
})
it('should ignore user supplied expires param', function(done){
var app = express();
app.use(function(req, res){
res.clearCookie('sid', { path: '/admin', expires: new Date() }).end();
});
request(app)
.get('/')
.expect('Set-Cookie', 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
.expect(200, done)
})
})
})