2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-05 13:55:21 -04:00
|
|
|
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
|
|
|
|
|
2017-05-05 02:53:38 -04:00
|
|
|
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
|
2019-01-02 02:29:17 -05:00
|
|
|
CustomEmoji.create!(name: 'test', upload_id: 9999)
|
2017-05-05 02:53:38 -04:00
|
|
|
|
|
|
|
emoji = Emoji.load_custom.first
|
|
|
|
|
|
|
|
expect(emoji.name).to eq('test')
|
|
|
|
expect(emoji.url).to eq(nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-13 14:03:59 -04:00
|
|
|
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
|
|
|
|
|
2016-07-05 13:55:21 -04:00
|
|
|
end
|