cf2104bac9dd3346ea2bc099137349726edf05d0.svn-base
1.37 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
// builtin
var assert = require('assert');
var cookie = require('..');
suite('serialize');
test('basic', function() {
assert.equal('foo=bar', cookie.serialize('foo', 'bar'));
assert.equal('foo=bar%20baz', cookie.serialize('foo', 'bar baz'));
});
test('path', function() {
assert.equal('foo=bar; Path=/', cookie.serialize('foo', 'bar', {
path: '/'
}));
});
test('secure', function() {
assert.equal('foo=bar; Secure', cookie.serialize('foo', 'bar', {
secure: true
}));
assert.equal('foo=bar', cookie.serialize('foo', 'bar', {
secure: false
}));
});
test('domain', function() {
assert.equal('foo=bar; Domain=example.com', cookie.serialize('foo', 'bar', {
domain: 'example.com'
}));
});
test('httpOnly', function() {
assert.equal('foo=bar; HttpOnly', cookie.serialize('foo', 'bar', {
httpOnly: true
}));
});
test('maxAge', function() {
assert.equal('foo=bar; Max-Age=1000', cookie.serialize('foo', 'bar', {
maxAge: 1000
}));
});
test('escaping', function() {
assert.deepEqual('cat=%2B%20', cookie.serialize('cat', '+ '));
});
test('parse->serialize', function() {
assert.deepEqual({ cat: 'foo=123&name=baz five' }, cookie.parse(
cookie.serialize('cat', 'foo=123&name=baz five')));
assert.deepEqual({ cat: ' ";/' }, cookie.parse(
cookie.serialize('cat', ' ";/')));
});