@@ -50,14 +50,27 @@ vows.describe('flash').addBatch({
50
50
assert . equal ( msgs [ 0 ] , 'Something went wrong' ) ;
51
51
assert . lengthOf ( Object . keys ( req . session . flash ) , 0 ) ;
52
52
} ,
53
- 'should set/get flash unicode message' : function ( err , req , res ) {
54
- const count = req . flash ( 'error' , 'a Ā 𐀀 文 🦄' ) ;
55
- assert . equal ( count , 1 ) ;
53
+ 'should be encoded to base64 in session' : function ( err , req , res ) {
54
+ req . flash ( 'error' , 'Something went wrong' ) ;
55
+ assert . equal ( req . session . flash . error [ 0 ] , 'U29tZXRoaW5nIHdlbnQgd3Jvbmc=' ) ;
56
+ const msgs = req . flash ( 'error' ) ;
57
+ assert . equal ( msgs [ 0 ] , 'Something went wrong' ) ;
58
+ } ,
59
+ 'should set/get unicode flash message' : function ( err , req , res ) {
60
+ req . flash ( 'error' , 'a Ā 𐀀 文 🦄' ) ;
56
61
assert . equal ( req . session . flash . error [ 0 ] , 'YSDEgCDwkICAIOaWhyDwn6aE' ) ;
57
62
const msgs = req . flash ( 'error' ) ;
58
- assert . lengthOf ( msgs , 1 ) ;
59
63
assert . equal ( msgs [ 0 ] , 'a Ā 𐀀 文 🦄' ) ;
60
- assert . lengthOf ( Object . keys ( req . session . flash ) , 0 ) ;
64
+ } ,
65
+ 'should get undecoded flash message when it is not been base64 encode in session' : function ( err , req , res ) {
66
+ req . flash ( 'error' , 'Something went wrong' ) ;
67
+ req . session . flash . error . push ( 'Something went wrong' ) ;
68
+ assert . equal ( req . session . flash . error [ 0 ] , 'U29tZXRoaW5nIHdlbnQgd3Jvbmc=' ) ;
69
+ assert . equal ( req . session . flash . error [ 1 ] , 'Something went wrong' ) ;
70
+ console . log ( req . session . flash . error ) ;
71
+ const msgs = req . flash ( 'error' ) ;
72
+ assert . equal ( msgs [ 0 ] , 'Something went wrong' ) ;
73
+ assert . equal ( msgs [ 1 ] , 'Something went wrong' ) ;
61
74
} ,
62
75
'should set multiple flash messages' : function ( err , req , res ) {
63
76
req . flash ( 'info' , 'Welcome' ) ;
0 commit comments