spec.plugins.session.js
This file
Path
spec/spec.plugins.session.js
108 lines · 3.2 KiB · JavaScript
Last changed by
Fixed broken specs due to use(Cookie) missingvisionmediabefore adoption1a9a367
History of this fileTake it
Started Session pluginvisionmediabefore adoption7238afb
lines 1–4why, one step back12describe 'Express'3 before_each4 reset()Fixed broken specs due to use(Cookie) missingvisionmediabefore adoption1a9a367
line 5why, one step back5 use(require('express/plugins/cookie').Cookie)Fixed sessions when testingvisionmediabefore adoption4d5a1b5
lines 6–7why, one step back6 use(Session = require('express/plugins/session').Session)7 Session.store.clear()Started Session pluginvisionmediabefore adoption7238afb
lines 8–10why, one step back8 end9 10 describe 'Session'Bulk of memory store based session support complete.visionmediabefore adoptionf4b4c03
lines 11–24why, one step back11 describe 'when sid cookie is not present'12 it 'should set sid cookie'13 get('/login', function(){ return '' })14 get('/login').headers['set-cookie'].should.match(/^sid=(\w+);/)15 end16 end17 18 describe 'when sid cookie is present'19 it 'should not set sid'20 get('/login', function(){ return '' })21 get('/login', { headers: { cookie: 'sid=123' }}).headers.should.not.have_property 'set-cookie'22 end23 end24 Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
line 25why, one step back25 describe 'session Store.Memory'Added session reapingvisionmediabefore adoption8ed99f6
line 26why, one step back26 before_eachRenamed MemoryStore -> Store.Memoryvisionmediabefore adoption542cab1
line 27why, one step back27 memory = new (require('express/plugins/session').Store.Memory)Added session reapingvisionmediabefore adoption8ed99f6
lines 28–29why, one step back28 end29 Bulk of memory store based session support complete.visionmediabefore adoptionf4b4c03
lines 30–41why, one step back30 it 'should persist'31 post('/login', function(){32 return this.session.name = 'tj'33 })34 get('/login', function(){35 return this.session.name36 })37 var headers = { headers: { cookie: 'sid=123' }}38 post('/login', headers)39 get('/login', headers).status.should.eql 20040 get('/login', headers).body.should.eql 'tj'41 endAdded session reapingvisionmediabefore adoption8ed99f6
line 42why, one step back42 Merge branch 'abstract-session'visionmediabefore adoption315c050
lines 43–48why, one step back43 describe '#toString()'44 it 'should return [Memory Store]'45 memory.toString().should.eql '[Memory Store]'46 end47 end48 Added session reapingvisionmediabefore adoption8ed99f6
lines 49–73why, one step back49 describe '#fetch()'50 describe 'when the session does not exist'51 it 'should return a new Session'52 memory.fetch('1').should.have_property 'lastAccess'53 end54 end55 56 describe 'when the session does exist'57 it 'should return the previous session'58 memory.commit({ id: '1', same: true })59 memory.fetch('1').should.have_property 'same', true60 end61 end62 end63 64 describe '#clear()'65 it 'should remove all sessions'66 memory.commit({ id: '1' })67 memory.commit({ id: '2' })68 memory.clear()69 memory.should.not.have_property '1'70 memory.should.not.have_property '2'71 end72 end73 Merge branch 'session-count'visionmediabefore adoptione083321
lines 74–81why, one step back74 describe '#length()'75 it 'should return the number of session'76 memory.commit({ id: '1' })77 memory.commit({ id: '2' })78 memory.length().should.eql 279 end80 end81 Added session reapingvisionmediabefore adoption8ed99f6
lines 82–104why, one step back82 describe '#destroy()'83 it 'should destroy a single session'84 memory.commit({ id: '1' })85 memory.commit({ id: '2' })86 memory.destroy('1')87 memory.store.should.not.have_property '1'88 memory.store.should.have_property '2'89 end90 end91 92 describe '#reap()'93 it 'should destroy sessions older than the given age in milliseconds'94 memory.commit({ id: '1', lastAccess: Number(new Date) - 300 })95 memory.commit({ id: '2', lastAccess: Number(new Date) - 250 })96 memory.commit({ id: '3', lastAccess: Number(new Date) - 100 })97 memory.commit({ id: '4', lastAccess: Number(new Date) })98 memory.reap(200)99 memory.store.should.not.have_property '1'100 memory.store.should.not.have_property '2'101 memory.store.should.have_property '3'102 memory.store.should.have_property '4'103 end104 endStarted Session pluginvisionmediabefore adoption7238afb
line 105why, one step back105 endAdded session reapingvisionmediabefore adoption8ed99f6
line 106why, one step back106 Started Session pluginvisionmediabefore adoption7238afb
lines 107–108why, one step back107 end108end