diff --git a/zerver/tests/frontend/common.js b/zerver/tests/frontend/common.js index 56a047dd41..165ae13750 100644 --- a/zerver/tests/frontend/common.js +++ b/zerver/tests/frontend/common.js @@ -192,6 +192,14 @@ exports.ltrim = function (str) { return str.replace(/^\s+/g, ''); }; +exports.rtrim = function (str) { + return str.replace(/\s+$/g, ''); +}; + +exports.trim = function (str) { + return exports.rtrim(exports.ltrim(str)); +}; + // Call get_rendered_messages and then check that the last few headings and // bodies match the specified arrays. exports.expected_messages = function (table, headings, bodies) { @@ -201,8 +209,8 @@ exports.expected_messages = function (table, headings, bodies) { var msg = exports.get_rendered_messages(table); casper.test.assertEquals( - msg.headings.slice(-headings.length).map(exports.normalize_spaces).map(exports.ltrim), - headings.map(exports.ltrim), + msg.headings.slice(-headings.length).map(exports.normalize_spaces).map(exports.trim), + headings.map(exports.trim), 'Got expected message headings'); casper.test.assertEquals(