FIX: allows to have custom emoji translation without static file (#9893)

This commit is contained in:
Joffrey JAFFEUX
2020-05-27 20:11:52 +02:00
committed by GitHub
parent 207b72ade1
commit 77801aa9be
11 changed files with 94 additions and 17 deletions

View File

@ -1040,6 +1040,27 @@ describe PrettyText do
end
end
describe "custom emoji translation" do
before do
PrettyText.reset_translations
SiteSetting.enable_emoji = true
SiteSetting.enable_emoji_shortcuts = true
plugin = Plugin::Instance.new
plugin.translate_emoji "0:)", "otter"
end
after do
Plugin::CustomEmoji.clear_cache
PrettyText.reset_translations
end
it "sets the custom translation" do
expect(PrettyText.cook("hello 0:)")).to match(/otter/)
end
end
it "replaces skin toned emoji" do
expect(PrettyText.cook("hello 👱🏿‍♀️")).to eq("<p>hello <img src=\"/images/emoji/twitter/blonde_woman/6.png?v=#{Emoji::EMOJI_VERSION}\" title=\":blonde_woman:t6:\" class=\"emoji\" alt=\":blonde_woman:t6:\"></p>")
expect(PrettyText.cook("hello 👩‍🎤")).to eq("<p>hello <img src=\"/images/emoji/twitter/woman_singer.png?v=#{Emoji::EMOJI_VERSION}\" title=\":woman_singer:\" class=\"emoji\" alt=\":woman_singer:\"></p>")