summaryrefslogtreecommitdiff
path: root/spec/presenters/award_emoji_presenter_spec.rb
blob: a23196282a2e5175dec9c8697dc64339e2f87d67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe AwardEmojiPresenter do
  let(:emoji_name) { 'thumbsup' }
  let(:award_emoji) { build(:award_emoji, name: emoji_name) }
  let(:presenter) { described_class.new(award_emoji) }
  let(:emoji) { TanukiEmoji.find_by_alpha_code(emoji_name) }

  describe '#description' do
    it { expect(presenter.description).to eq emoji.description }
  end

  describe '#unicode' do
    it { expect(presenter.unicode).to eq emoji.hex }
  end

  describe '#unicode_version' do
    it { expect(presenter.unicode_version).to eq('6.0') }
  end

  describe '#emoji' do
    it { expect(presenter.emoji).to eq emoji.codepoints }
  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