# frozen_string_literal: true require_relative "common" describe "Sanitize::Transformers::CleanComment" do make_my_diffs_pretty! parallelize_me! describe "when :allow_comments is false" do before do @s = Sanitize.new(allow_comments: false, elements: ["div"]) end it "should remove comments" do _(@s.fragment("foo bar")).must_equal "foo bar" _(@s.fragment("foo bar")).must_equal "foo bar" _(@s.fragment("foo --> -->bar")).must_equal "foo --> -->bar" _(@s.fragment("foo
>bar
")).must_equal "foo
>bar
" # Special case: the comment markup is inside a ")).must_equal "" _(Sanitize.fragment("", allow_comments: false, elements: ["script"])) .must_equal "" end end describe "when :allow_comments is true" do before do @s = Sanitize.new(allow_comments: true, elements: ["div"]) end it "should allow comments" do _(@s.fragment("foo bar")).must_equal "foo bar" _(@s.fragment("foo " _(@s.fragment("foo " _(@s.fragment("foo bar")).must_equal "foo bar" _(@s.fragment("foo --> -->bar")).must_equal "foo --> -->bar" _(@s.fragment("foo
>bar
")).must_equal "foo
>bar
" _(Sanitize.fragment("", allow_comments: true, elements: ["script"])) .must_equal "" end end end