# 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) { " \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) { '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