2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-11 12:40:12 +01:00
|
|
|
describe HtmlToStringHelper do
|
|
|
|
describe "#html_to_string" do
|
|
|
|
describe 'does not change plain text' do
|
|
|
|
it { expect(helper.html_to_string('text')).to eq('text') }
|
|
|
|
end
|
|
|
|
|
2017-12-12 10:06:50 +01:00
|
|
|
describe 'deals with empty / nil strings' do
|
|
|
|
it { expect(helper.html_to_string(nil)).to eq(nil) }
|
|
|
|
it { expect(helper.html_to_string('')).to eq("") }
|
|
|
|
end
|
|
|
|
|
2017-12-11 12:40:12 +01:00
|
|
|
describe 'deals with <br>' do
|
|
|
|
it { expect(helper.html_to_string('new<br>line')).to eq("new\nline") }
|
|
|
|
it { expect(helper.html_to_string('new<br/>line')).to eq("new\nline") }
|
|
|
|
it { expect(helper.html_to_string('new<br />line')).to eq("new\nline") }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'deals with <p>' do
|
|
|
|
it { expect(helper.html_to_string('<p>p1</p><p>p2</p>')).to eq("p1\np2\n") }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'strip other tags' do
|
|
|
|
it { expect(helper.html_to_string('<i>italic</i>')).to eq('italic') }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|