mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 03:42:16 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
48 lines
1.2 KiB
Ruby
48 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe Emoji do
|
|
|
|
it "returns the correct codepoints" do
|
|
expect(Emoji.replacement_code('1f47d').codepoints).to eq([128125])
|
|
end
|
|
|
|
it "handles multiple codepoints" do
|
|
expect(Emoji.replacement_code('1f1e9-1f1ea').codepoints).to eq([127465, 127466])
|
|
end
|
|
|
|
it "returns nil for weird cases" do
|
|
expect(Emoji.replacement_code('32')).to be_nil
|
|
expect(Emoji.replacement_code('robin')).to be_nil
|
|
end
|
|
|
|
describe '.load_custom' do
|
|
describe 'when a custom emoji has an invalid upload_id' do
|
|
it 'should return the custom emoji without a URL' do
|
|
CustomEmoji.create!(name: 'test', upload_id: 9999)
|
|
|
|
emoji = Emoji.load_custom.first
|
|
|
|
expect(emoji.name).to eq('test')
|
|
expect(emoji.url).to eq(nil)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '.lookup_unicode' do
|
|
it 'should return the emoji' do
|
|
expect(Emoji.lookup_unicode("blonde_man")).to eq("👱")
|
|
end
|
|
|
|
it 'should return an aliased emoji' do
|
|
expect(Emoji.lookup_unicode("anger_right")).to eq("🗯")
|
|
end
|
|
|
|
it 'should return a skin toned emoji' do
|
|
expect(Emoji.lookup_unicode("blonde_woman:t6")).to eq("👱🏿♀️")
|
|
end
|
|
end
|
|
|
|
end
|