spec.plugins.cookie.js
This file
Path
spec/spec.plugins.cookie.js
100 lines · 3.1 KiB · JavaScript
Last changed by
Merge branch 'fix-cookies'visionmediabefore adoption2b92e40
History of this fileTake it
The walk stopped after 200 commits: lines older than 48bea03 point at it.
Fixing cookie specsvisionmediabefore adoption48bea03
lines 1–12why, one step back12describe 'Express'3 before_each4 reset()5 use(require('express/plugins/cookie').Cookie)6 compileCookie = require('express/plugins/cookie').compileCookie7 parseCookie = require('express/plugins/cookie').parseCookie8 end9 10 describe 'Cookie'11 describe 'compileCookie()'12 it 'should return a cookie string'cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
line 13why, one step back13 var options = {Fixing cookie specsvisionmediabefore adoption48bea03
lines 14–16why, one step back14 path: '/',15 domain: '.vision-media.ca'16 }cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
line 17why, one step back17 compileCookie('foo', 'bar', options).should.eql 'foo=bar; path=/; domain=.vision-media.ca'Fixing cookie specsvisionmediabefore adoption48bea03
lines 18–20why, one step back18 end19 20 it 'should currectly format any Date objects'cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
line 21why, one step back21 var options = {Fixing cookie specsvisionmediabefore adoption48bea03
lines 22–25why, one step back22 expires: new Date('May 25, 1987 11:13:00'),23 path: '/foo',24 domain: '.vision-media.ca'25 }cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
line 26why, one step back26 compileCookie('foo', 'bar', options).should.eql 'foo=bar; expires=Mon, 25-May-1987 11:13:00 GMT; path=/foo; domain=.vision-media.ca'Fixing cookie specsvisionmediabefore adoption48bea03
lines 27–29why, one step back27 end28 29 it 'should convert true to a key without a value'cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
line 30why, one step back30 var options = {Fixing cookie specsvisionmediabefore adoption48bea03
lines 31–34why, one step back31 path: '/',32 secure: true,33 httpOnly: true34 }cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
line 35why, one step back35 compileCookie('foo', 'bar', options).should.eql 'foo=bar; path=/; secure; httpOnly'Fixing cookie specsvisionmediabefore adoption48bea03
line 36why, one step back36 endCompiles without trailing ; when no options are presentvisionmediabefore adoptionefb75a7
lines 37–40why, one step back37 38 it 'should compile without options'39 compileCookie('foo', 'bar').should.eql 'foo=bar'40 endFixing cookie specsvisionmediabefore adoption48bea03
lines 41–48why, one step back41 end42 43 describe 'parseCookie()'44 it 'should parse cookie key/value pairs'45 var attrs = 'sid=1232431234234; data=foo'46 parseCookie(attrs).should.eql { sid: '1232431234234', data: 'foo' }47 end48 cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
lines 49–51why, one step back49 it 'should preserve case'50 var attrs = 'SID=1232431234234; Data=foo'51 parseCookie(attrs).should.eql { SID: '1232431234234', Data: 'foo' }Fixing cookie specsvisionmediabefore adoption48bea03
lines 52–55why, one step back52 end53 54 it 'should disregard ad-hoc invalid whitespace'55 var attrs = ' SID = 1232431234234 ; data = foo'cookie() now accepts name/val paramsvisionmediabefore adoptionf2c484d
line 56why, one step back56 parseCookie(attrs).should.eql { SID: '1232431234234', data: 'foo' }Fixing cookie specsvisionmediabefore adoption48bea03
lines 57–68why, one step back57 end58 end59 60 describe 'on'61 describe 'request'62 it 'should parse the Cookie header'63 get('/user', function(){64 return this.cookie('foo')65 })66 get('/user', { headers: { cookie: 'foo=bar' }}).body.should.eql 'bar'67 end68 endMultiple cookie supportvisionmediabefore adoptiondd07776
lines 69–84why, one step back69 70 describe 'response'71 it 'should populate Set-Cookie'72 get('/user', function(){73 this.cookie('SID', '732423sdfs73243', { path: '/', secure: true })74 return '' 75 })76 get('/user').headers['set-cookie'].should.eql 'SID=732423sdfs73243; path=/; secure'77 end78 79 it 'should join multiple cookies'80 get('/user', function(){81 this.cookie('SID', '732423sdfs73243', { path: '/', secure: true })82 this.cookie('foo', 'bar')83 return '' 84 })Merge branch 'fix-cookies'visionmediabefore adoption2b92e40
line 85why, one step back85 get('/user').headers['set-cookie'].should.eql 'SID=732423sdfs73243; path=/; secure, foo=bar; path=/'Multiple cookie supportvisionmediabefore adoptiondd07776
lines 86–87why, one step back86 end87 endFixing cookie specsvisionmediabefore adoption48bea03
lines 88–100why, one step back88 end89 90 describe 'cookie()'91 it 'should get request cookie values'92 get('/user', function(){93 return this.cookie('foo')94 })95 get('/user', { headers: { cookie: 'foo=bar' }}).body.should.eql 'bar'96 end97 end98 99 end100end