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.
This commit is contained in:
Rohitt Vashishtha 2018-03-25 21:40:59 +05:30 committed by Tim Abbott
parent 6dda3fe83e
commit b976447102
1 changed files with 9 additions and 11 deletions

View File

@ -292,6 +292,12 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver
expected: '<p>@*notagroup*</p>'},
{input: 'This is a realm filter `hello` with text after it',
expected: '<p>This is a realm filter <code>hello</code> with text after it</p>'},
// Test the emoticon conversion
{input: ':)',
expected: '<p>:)</p>'},
{input: ':)',
expected: '<p><span class="emoji emoji-1f603" title="smiley">:smiley:</span></p>',
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('<p><span class="emoji emoji-1f603" title="smiley">:smiley:</span></p>', message.content);
page_params.translate_emoticons = false;
}());
(function test_subject_links() {