import { emojiSearch, IMAGE_VERSION as v } from 'pretty-text/emoji'; import { emojiUnescape } from 'discourse/lib/text'; module('lib:emoji'); function testUnescape(input, expected, description) { equal(emojiUnescape(input), expected, description); }; test("emojiUnescape", () => { 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 slight_smile", "emoticons are still supported"); testUnescape("With emoji :O: :frog: :smile:", `With emoji O frog smile`, "title with emoji"); testUnescape("a:smile:a", "a:smile:a", "word characters not allowed next to emoji"); testUnescape("(:frog:) :)", `(frog) slight_smile`, "non-word characters allowed next to emoji"); testUnescape(":smile: hi", `smile hi`, "start of line"); testUnescape("hi :smile:", `hi smile`, "end of line"); }); test("Emoji search", () => { // able to find an alias equal(emojiSearch("+1").length, 1); // able to find middle of line search equal(emojiSearch("check", {maxResults: 3}).length, 3); });