spec.plugins.flash.js
This file
Path
spec/spec.plugins.flash.js
78 lines · 2.9 KiB · JavaScript
Last changed by
Merge branch 'integration'visionmediabefore adoption33443d9
History of this fileTake it
Merge branch 'flash'visionmediabefore adoption3863a76
lines 1–8why, one step back12describe 'Express'3 before_each4 reset()5 use(require('express/plugins/cookie').Cookie)6 use(require('express/plugins/session').Session)7 use(require('express/plugins/flash').Flash)8 Session.store.clear()Merge branch 'integration'visionmediabefore adoption33443d9
lines 9–10why, one step back9 var sess = new Base(123)10 Session.store.commit(sess, function(){})Merge branch 'flash'visionmediabefore adoption3863a76
lines 11–13why, one step back11 end12 13 describe 'Flash'Typovisionmediabefore adoptione1152f6
line 14why, one step back14 describe '#flash()'Fixed Request#flash() specsvisionmediabefore adoptionf2637c6
lines 15–17why, one step back15 describe 'given a type and msg'16 it 'should push a flash message'17 var headers = { headers: { cookie: 'sid=123' }}Revert "Fail to test CI"visionmediabefore adoptionce82a91
line 18why, one step back18 post('/', function(){ return this.flash('info', 'email sent') })Fixed Request#flash() specsvisionmediabefore adoptionf2637c6
lines 19–23why, one step back19 get('/', function(){ return this.flash('info').join(', ') })20 post('/', headers)21 post('/', headers)22 get('/', headers).body.should.eql 'email sent, email sent'23 endMerge branch 'flash'visionmediabefore adoption3863a76
lines 24–25why, one step back24 end25 Fixed Request#flash() specsvisionmediabefore adoptionf2637c6
lines 26–45why, one step back26 describe 'given a type'27 describe 'when no messages have been pushed'28 it 'should return null'29 var headers = { headers: { cookie: 'sid=123' }}30 get('/', function(){ return this.flash('info') || 'empty' })31 get('/', headers).body.should.eql 'empty'32 end33 end34 35 describe 'when messages have been pushed'36 it 'should persist only until flushed'37 var headers = { headers: { cookie: 'sid=123' }}38 post('/', function(){ return this.flash('info', 'email sent') })39 get('/', function(){ return (this.flash('info') || ['nope!']).join(', ') })40 post('/', headers)41 post('/', headers)42 get('/', headers).body.should.eql 'email sent, email sent'43 get('/', headers).body.should.eql 'nope!'44 end45 endRequest#flash() without args now returns all flashesvisionmediabefore adoption50e0593
lines 46–74why, one step back46 47 describe 'given no arguments'48 it 'should provide access to all types'49 var flash, headers = { headers: { cookie: 'sid=123' }}50 post('/', function(){ return this.flash('info', 'email sent') })51 post('/error', function(){ return this.flash('error', 'email failed to send') })52 get('/', function(){ return flash = this.flash(), '' })53 post('/', headers)54 post('/', headers)55 post('/error', headers)56 get('/')57 flash.should.eql { info: ['email sent', 'email sent'], error: ['email failed to send'] }58 end59 60 it 'should persist only until flushed'61 var flash, headers = { headers: { cookie: 'sid=123' }}62 post('/', function(){ return this.flash('info', 'email sent') })63 post('/error', function(){ return this.flash('error', 'email failed to send') })64 get('/', function(){ return flash = this.flash(), '' })65 post('/', headers)66 post('/', headers)67 post('/error', headers)68 get('/', headers)69 flash.should.eql { info: ['email sent', 'email sent'], error: ['email failed to send'] }70 get('/', headers)71 flash.should.eql {}72 end73 end74 Merge branch 'flash'visionmediabefore adoption3863a76
lines 75–78why, one step back75 end76 end77 end78end