From 123a343d116d3e83cbd04460cc7bd0b6f3d208c4 Mon Sep 17 00:00:00 2001 From: David Underwood Date: Sun, 1 Apr 2018 17:55:42 -0400 Subject: [WIP] Enable custom emoji on account pages and in the sidebar (#6124) Federate custom emojis with accounts --- spec/lib/formatter_spec.rb | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'spec') diff --git a/spec/lib/formatter_spec.rb b/spec/lib/formatter_spec.rb index 67fbfe92d..6e849f379 100644 --- a/spec/lib/formatter_spec.rb +++ b/spec/lib/formatter_spec.rb @@ -394,6 +394,45 @@ RSpec.describe Formatter do end end + context 'with custom_emojify option' do + let!(:emoji) { Fabricate(:custom_emoji) } + + before { account.note = text } + subject { Formatter.instance.simplified_format(account, custom_emojify: true) } + + context 'with emoji at the start' do + let(:text) { ':coolcat: Beep boop' } + + it 'converts shortcode to image tag' do + is_expected.to match(/

:coolcat:alert("Hello")' end + + context 'with custom_emojify option' do + let!(:emoji) { Fabricate(:custom_emoji, domain: remote_account.domain) } + + before { remote_account.note = text } + + subject { Formatter.instance.simplified_format(remote_account, custom_emojify: true) } + + context 'with emoji at the start' do + let(:text) { '

:coolcat: Beep boop
' } + + it 'converts shortcode to image tag' do + is_expected.to match(/

:coolcat:Beep :coolcat: boop

' } + + it 'converts shortcode to image tag' do + is_expected.to match(/Beep :coolcat::coolcat::coolcat:

' } + + it 'does not touch the shortcodes' do + is_expected.to match(/

:coolcat::coolcat:<\/p>/) + end + end + + context 'with emoji at the end' do + let(:text) { '

Beep boop
:coolcat:

' } + + it 'converts shortcode to image tag' do + is_expected.to match(/