# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ require 'rails_helper' RSpec.describe HtmlSanitizer::RemoveLineBreaks do let(:scrubber) { described_class.new } describe('#scrubber') do subject(:actual) { fragment.scrub!(scrubber).to_html } let(:fragment) { Loofah.fragment(input) } describe 'removes newline-only spans' do let(:input) { "
testa\n\r\n
" } let(:target) { "
testa\n
" } it { is_expected.to match target } end describe 'removes newline-only in divs' do let(:input) { "
test
a\n
\r\n\n\n
" } let(:target) { "
test
a\n
\n
" } it { is_expected.to match target } end describe 'does not remove newlines in other elements' do let(:input) { "
testa\n
" } let(:target) { "
testa\n\n
" } it { is_expected.to match target } end end end