# frozen_string_literal: true
RSpec.shared_examples 'emoji filter' do
it 'keeps whitespace intact' do
doc = filter("This deserves a #{emoji_name}, big time.")
expect(doc.to_html).to match(/^This deserves a , big time\.\z/)
end
it 'does not match emoji in a string' do
doc = filter("'2a00:a4c0#{emoji_name}:1'")
expect(doc.css('gl-emoji')).to be_empty
end
it 'ignores non existent/unsupported emoji' do
exp = ':foo:
'
doc = filter(exp)
expect(doc.to_html).to eq(exp)
end
it 'matches with adjacent text' do
doc = filter("#{emoji_name.delete(':')} (#{emoji_name})")
expect(doc.css('gl-emoji').size).to eq 1
end
it 'does not match emoji in a pre tag' do
doc = filter("#{emoji_name}
")
expect(doc.css('img')).to be_empty
end
it 'does not match emoji in code tag' do
doc = filter("#{emoji_name} wow
")
expect(doc.css('img')).to be_empty
end
it 'does not match emoji in tt tag' do
doc = filter("#{emoji_name} yes!
")
expect(doc.css('img')).to be_empty
end
end