Skip to content

Commit

Permalink
test: add handle unicode flash messages test
Browse files Browse the repository at this point in the history
  • Loading branch information
EastSun5566 committed Sep 25, 2024
1 parent a8b09cd commit d65b423
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/flash-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ var flash = require('flash');
function MockRequest() {
this.session = {};
}

function MockRequestWithoutSession() {
}

function MockResponse() {
}
function MockRequestWithoutSession() {}
function MockResponse() {}


vows.describe('flash').addBatch({
Expand Down Expand Up @@ -54,6 +50,15 @@ vows.describe('flash').addBatch({
assert.equal(msgs[0], 'Something went wrong');
assert.lengthOf(Object.keys(req.session.flash), 0);
},
'should set/get flash unicode message' : function(err, req, res) {
const count = req.flash('error', 'a Ā 𐀀 文 🦄');
assert.equal(count, 1);
assert.equal(req.session.flash.error[0], 'YSDEgCDwkICAIOaWhyDwn6aE');
const msgs = req.flash('error');
assert.lengthOf(msgs, 1);
assert.equal(msgs[0], 'a Ā 𐀀 文 🦄');
assert.lengthOf(Object.keys(req.session.flash), 0);
},
'should set multiple flash messages' : function(err, req, res) {
req.flash('info', 'Welcome');
var count = req.flash('info', 'Check out this great new feature');
Expand Down

0 comments on commit d65b423

Please sign in to comment.