From b976447102f29a28bede91cf95d5cfa48c4d8b35 Mon Sep 17 00:00:00 2001 From: Rohitt Vashishtha Date: Sun, 25 Mar 2018 21:40:59 +0530 Subject: [PATCH] markdown: Test the translate_emoticons flag. The main testing of the translate emoticons code is in the node_tests/emoji.js file. This code just checks if the setting to enable/disable the emoticon translation is being honored. --- frontend_tests/node_tests/markdown.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index e8e3852170..db095bd9d2 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -292,6 +292,12 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver expected: '

@*notagroup*

'}, {input: 'This is a realm filter `hello` with text after it', expected: '

This is a realm filter hello with text after it

'}, + // Test the emoticon conversion + {input: ':)', + expected: '

:)

'}, + {input: ':)', + expected: '

:smiley:

', + translate_emoticons: true}, ]; // We remove one of the unicode emoji we put as input in one of the test @@ -300,6 +306,9 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver delete emoji_codes.codepoint_to_name['1f6b2']; test_cases.forEach(function (test_case) { + // Disable emoji conversion by default. + page_params.translate_emoticons = test_case.translate_emoticons || false; + var input = test_case.input; var expected = test_case.expected; @@ -309,17 +318,6 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver assert.equal(expected, output); }); - - // Here to arrange 100% test coverage for the new emoticons code - // path. TODO: Have a better way to test this setting in both - // states, once we implement the local echo feature properly. - // Probably a good technique would be to support toggling the - // page_params setting inside the `test_cases.forEach` loop above. - page_params.translate_emoticons = true; - var message = {raw_content: ":)"}; - markdown.apply_markdown(message); - assert.equal('

:smiley:

', message.content); - page_params.translate_emoticons = false; }()); (function test_subject_links() {