mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Render emojis on GitHub labels when oneboxing an issue. (#13531)
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
# coding: utf-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe EmojiHelper do
|
||||
before do
|
||||
Plugin::CustomEmoji.clear_cache
|
||||
end
|
||||
|
||||
after do
|
||||
Plugin::CustomEmoji.clear_cache
|
||||
end
|
||||
|
||||
describe "emoji_codes_to_img" do
|
||||
it "replaces emoji codes by images" do
|
||||
Plugin::CustomEmoji.register("xxxxxx", "/public/xxxxxx.png")
|
||||
|
||||
str = "This is a good day :xxxxxx: :woman: :man:t4:"
|
||||
replaced_str = helper.emoji_codes_to_img(str)
|
||||
|
||||
expect(replaced_str).to eq("This is a good day <img src=\"/public/xxxxxx.png\" title=\"xxxxxx\" class=\"emoji\" alt=\"xxxxxx\"> <img src=\"/images/emoji/twitter/woman.png?v=#{Emoji::EMOJI_VERSION}\" title=\"woman\" class=\"emoji\" alt=\"woman\"> <img src=\"/images/emoji/twitter/man/4.png?v=#{Emoji::EMOJI_VERSION}\" title=\"man:t4\" class=\"emoji\" alt=\"man:t4\">")
|
||||
end
|
||||
|
||||
it "doesn't replace if code doesn't exist" do
|
||||
str = "This is a good day :woman: :foo: :bar:t4: :man:t8:"
|
||||
replaced_str = helper.emoji_codes_to_img(str)
|
||||
|
||||
expect(replaced_str).to eq("This is a good day <img src=\"/images/emoji/twitter/woman.png?v=#{Emoji::EMOJI_VERSION}\" title=\"woman\" class=\"emoji\" alt=\"woman\"> :foo: :bar:t4: :man:t8:")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -87,4 +87,24 @@ describe Emoji do
|
||||
end
|
||||
end
|
||||
|
||||
describe '.codes_to_img' do
|
||||
before { Plugin::CustomEmoji.clear_cache }
|
||||
after { Plugin::CustomEmoji.clear_cache }
|
||||
|
||||
it "replaces emoji codes by images" do
|
||||
Plugin::CustomEmoji.register("xxxxxx", "/public/xxxxxx.png")
|
||||
|
||||
str = "This is a good day :xxxxxx: :woman: :man:t4:"
|
||||
replaced_str = described_class.codes_to_img(str)
|
||||
|
||||
expect(replaced_str).to eq("This is a good day <img src=\"/public/xxxxxx.png\" title=\"xxxxxx\" class=\"emoji\" alt=\"xxxxxx\"> <img src=\"/images/emoji/twitter/woman.png?v=#{Emoji::EMOJI_VERSION}\" title=\"woman\" class=\"emoji\" alt=\"woman\"> <img src=\"/images/emoji/twitter/man/4.png?v=#{Emoji::EMOJI_VERSION}\" title=\"man:t4\" class=\"emoji\" alt=\"man:t4\">")
|
||||
end
|
||||
|
||||
it "doesn't replace if code doesn't exist" do
|
||||
str = "This is a good day :woman: :foo: :bar:t4: :man:t8:"
|
||||
replaced_str = described_class.codes_to_img(str)
|
||||
|
||||
expect(replaced_str).to eq("This is a good day <img src=\"/images/emoji/twitter/woman.png?v=#{Emoji::EMOJI_VERSION}\" title=\"woman\" class=\"emoji\" alt=\"woman\"> :foo: :bar:t4: :man:t8:")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user