discourse/test/javascripts/lib/emoji-test.js.es6

32 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-05-31 22:33:42 -04:00
module('emoji');
2015-08-26 14:57:47 -04:00
var testUnescape = function(input, expected, description) {
var unescaped = Discourse.Emoji.unescape(input);
equal(unescaped, expected, description);
};
test("Emoji.unescape", function(){
const v = Discourse.Emoji.ImageVersion;
2015-08-26 14:57:47 -04:00
testUnescape("Not emoji :O) :frog) :smile)", "Not emoji :O) :frog) :smile)", "title without emoji");
testUnescape("Not emoji :frog :smile", "Not emoji :frog :smile", "end colon is not optional");
testUnescape("emoticons :)", "emoticons <img src='/images/emoji/emoji_one/slight_smile.png?v=2' title='slight_smile' alt='slight_smile' class='emoji'>", "emoticons are still supported");
2015-08-26 14:57:47 -04:00
testUnescape("With emoji :O: :frog: :smile:",
`With emoji <img src='/images/emoji/emoji_one/o.png?v=${v}' title='O' alt='O' class='emoji'> <img src='/images/emoji/emoji_one/frog.png?v=${v}' title='frog' alt='frog' class='emoji'> <img src='/images/emoji/emoji_one/smile.png?v=${v}' title='smile' alt='smile' class='emoji'>`,
2015-08-26 14:57:47 -04:00
"title with emoji");
testUnescape("a:smile:a", "a:smile:a", "word characters not allowed next to emoji");
testUnescape("(:frog:) :)", `(<img src='/images/emoji/emoji_one/frog.png?v=${v}' title='frog' alt='frog' class='emoji'>) <img src='/images/emoji/emoji_one/slight_smile.png?v=${v}' title='slight_smile' alt='slight_smile' class='emoji'>`, "non-word characters allowed next to emoji");
testUnescape(":smile: hi", `<img src='/images/emoji/emoji_one/smile.png?v=${v}' title='smile' alt='smile' class='emoji'> hi`, "start of line");
testUnescape("hi :smile:", `hi <img src='/images/emoji/emoji_one/smile.png?v=${v}' title='smile' alt='smile' class='emoji'>`, "end of line");
2015-08-26 14:57:47 -04:00
});
2015-05-31 22:33:42 -04:00
test("Emoji.search", function(){
// able to find an alias
equal(Discourse.Emoji.search("+1").length, 1);
2015-05-31 22:33:42 -04:00
});