# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ require 'rails_helper' RSpec.describe HtmlSanitizer::Scrubber::Cleanup do let(:scrubber) { described_class.new } describe('#scrubber') do subject(:actual) do # export with extra options to avoid html indentation fragment.scrub!(scrubber) .to_html save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML ^ Nokogiri::XML::Node::SaveOptions::FORMAT end let(:fragment) { Loofah.fragment(input) } context 'when extra spaces' do let(:input) { "
\n
" } let(:target) { '
' } it { is_expected.to eq target } end context 'when extra spaces in preformatted tags' do let(:input) { " \n " } let(:target) { " \n " } it { is_expected.to eq target } end context 'when has extra spaces but no siblings' do let(:input) { ' content ' } let(:target) { ' content ' } it { is_expected.to eq target } end context 'when div has extra spaces' do let(:input) { '
test
content
' } let(:target) { '
test
content
' } it { is_expected.to eq target } end context 'when span has extra spaces' do let(:input) { '
test
content ' } let(:target) { '
test
content ' } it { is_expected.to eq target } end context 'when has previous' do let(:input) { '
test
content ' } let(:target) { '
test
content' } it { is_expected.to eq target } end context 'when has next div' do let(:input) { '
content
test
' } let(:target) { '
content
test
' } it { is_expected.to eq target } end context 'when has next span' do let(:input) { '
content test
' } let(:target) { '
content test
' } it { is_expected.to eq target } end context 'when p has style with white-space property' do let(:input) do '

Hi! This is a dummy text for Zammad to test multi-line text that is wrapped in a preformatted text block.

' end let(:target) do '

Hi! This is a dummy text for Zammad to test multi-line text that is wrapped in a preformatted text block.

' end it { is_expected.to eq target } end end end