# encoding: utf-8 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