From d65b42303e095074f9b7e66a6b05d8b8f7b55dc0 Mon Sep 17 00:00:00 2001 From: Michael Wang Date: Wed, 25 Sep 2024 16:43:39 +0800 Subject: [PATCH] test: add handle unicode flash messages test --- test/flash-test.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/flash-test.js b/test/flash-test.js index 3502d9a..2807a1f 100644 --- a/test/flash-test.js +++ b/test/flash-test.js @@ -7,12 +7,8 @@ var flash = require('flash'); function MockRequest() { this.session = {}; } - -function MockRequestWithoutSession() { -} - -function MockResponse() { -} +function MockRequestWithoutSession() {} +function MockResponse() {} vows.describe('flash').addBatch({ @@ -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');