spec.plugins.flash.js
This file
Path
spec/spec.plugins.flash.js
76 lines · 2.9 KiB · JavaScript
Last changed by
Typovisionmediabefore adoptione1152f6
History of this fileTake it
Merge branch 'flash'visionmediabefore adoption3863a76
lines 1–11why, 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()9 end10 11 describe 'Flash'Typovisionmediabefore adoptione1152f6
line 12why, one step back12 describe '#flash()'Fixed Request#flash() specsvisionmediabefore adoptionf2637c6
lines 13–21why, one step back13 describe 'given a type and msg'14 it 'should push a flash message'15 var headers = { headers: { cookie: 'sid=123' }}16 post('/', function(){ return this.flash('info', 'email sent') })17 get('/', function(){ return this.flash('info').join(', ') })18 post('/', headers)19 post('/', headers)20 get('/', headers).body.should.eql 'email sent, email sent'21 endMerge branch 'flash'visionmediabefore adoption3863a76
lines 22–23why, one step back22 end23 Fixed Request#flash() specsvisionmediabefore adoptionf2637c6
lines 24–43why, one step back24 describe 'given a type'25 describe 'when no messages have been pushed'26 it 'should return null'27 var headers = { headers: { cookie: 'sid=123' }}28 get('/', function(){ return this.flash('info') || 'empty' })29 get('/', headers).body.should.eql 'empty'30 end31 end32 33 describe 'when messages have been pushed'34 it 'should persist only until flushed'35 var headers = { headers: { cookie: 'sid=123' }}36 post('/', function(){ return this.flash('info', 'email sent') })37 get('/', function(){ return (this.flash('info') || ['nope!']).join(', ') })38 post('/', headers)39 post('/', headers)40 get('/', headers).body.should.eql 'email sent, email sent'41 get('/', headers).body.should.eql 'nope!'42 end43 endRequest#flash() without args now returns all flashesvisionmediabefore adoption50e0593
lines 44–72why, one step back44 45 describe 'given no arguments'46 it 'should provide access to all types'47 var flash, headers = { headers: { cookie: 'sid=123' }}48 post('/', function(){ return this.flash('info', 'email sent') })49 post('/error', function(){ return this.flash('error', 'email failed to send') })50 get('/', function(){ return flash = this.flash(), '' })51 post('/', headers)52 post('/', headers)53 post('/error', headers)54 get('/')55 flash.should.eql { info: ['email sent', 'email sent'], error: ['email failed to send'] }56 end57 58 it 'should persist only until flushed'59 var flash, headers = { headers: { cookie: 'sid=123' }}60 post('/', function(){ return this.flash('info', 'email sent') })61 post('/error', function(){ return this.flash('error', 'email failed to send') })62 get('/', function(){ return flash = this.flash(), '' })63 post('/', headers)64 post('/', headers)65 post('/error', headers)66 get('/', headers)67 flash.should.eql { info: ['email sent', 'email sent'], error: ['email failed to send'] }68 get('/', headers)69 flash.should.eql {}70 end71 end72 Merge branch 'flash'visionmediabefore adoption3863a76
lines 73–76why, one step back73 end74 end75 end76end