forked from expressjs/session
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie.js
More file actions
62 lines (48 loc) · 1.77 KB
/
Copy pathcookie.js
File metadata and controls
62 lines (48 loc) · 1.77 KB
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
var assert = require('assert')
var Cookie = require('../session/cookie')
describe('new Cookie()', function () {
it('should create a new cookie object', function () {
assert.equal(typeof new Cookie(), 'object')
})
it('should default expires to null', function () {
var cookie = new Cookie()
assert.strictEqual(cookie.expires, null)
})
it('should default httpOnly to true', function () {
var cookie = new Cookie()
assert.strictEqual(cookie.httpOnly, true)
})
it('should default path to "/"', function () {
var cookie = new Cookie()
assert.strictEqual(cookie.path, '/')
})
it('should default maxAge to null', function () {
var cookie = new Cookie()
assert.strictEqual(cookie.maxAge, null)
})
describe('with options', function () {
it('should create a new cookie object', function () {
assert.equal(typeof new Cookie({}), 'object')
})
it('should reject non-objects', function () {
assert.throws(function () { new Cookie(42) }, /argument options/)
assert.throws(function () { new Cookie('foo') }, /argument options/)
assert.throws(function () { new Cookie(true) }, /argument options/)
assert.throws(function () { new Cookie(function () {}) }, /argument options/)
})
it('should set expires', function () {
var expires = new Date()
var cookie = new Cookie({ expires: expires })
assert.strictEqual(cookie.expires, expires)
assert.notStrictEqual(cookie.maxAge, null)
})
it('should set httpOnly', function () {
var cookie = new Cookie({ httpOnly: false })
assert.strictEqual(cookie.httpOnly, false)
})
it('should set path', function () {
var cookie = new Cookie({ path: '/foo' })
assert.strictEqual(cookie.path, '/foo')
})
})
})