2019-06-21 00:45:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe AwardEmojiPresenter do
|
2019-06-21 00:45:27 -04:00
|
|
|
let(:emoji_name) { 'thumbsup' }
|
|
|
|
let(:award_emoji) { build(:award_emoji, name: emoji_name) }
|
|
|
|
let(:presenter) { described_class.new(award_emoji) }
|
2021-10-19 17:12:08 -04:00
|
|
|
let(:emoji) { TanukiEmoji.find_by_alpha_code(emoji_name) }
|
2019-06-21 00:45:27 -04:00
|
|
|
|
|
|
|
describe '#description' do
|
2021-10-19 17:12:08 -04:00
|
|
|
it { expect(presenter.description).to eq emoji.description }
|
2019-06-21 00:45:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#unicode' do
|
2021-10-19 17:12:08 -04:00
|
|
|
it { expect(presenter.unicode).to eq emoji.hex }
|
2019-06-21 00:45:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#unicode_version' do
|
2021-10-19 17:12:08 -04:00
|
|
|
it { expect(presenter.unicode_version).to eq('6.0') }
|
2019-06-21 00:45:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#emoji' do
|
2021-10-19 17:12:08 -04:00
|
|
|
it { expect(presenter.emoji).to eq emoji.codepoints }
|
2019-06-21 00:45:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when presenting an award emoji with an invalid name' do
|
|
|
|
let(:emoji_name) { 'invalid-name' }
|
|
|
|
|
|
|
|
it 'returns nil for all properties' do
|
|
|
|
expect(presenter.description).to be_nil
|
|
|
|
expect(presenter.emoji).to be_nil
|
|
|
|
expect(presenter.unicode).to be_nil
|
|
|
|
expect(presenter.unicode_version).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|