Skip to content

Commit

Permalink
Add a couple more tests for #128.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrove committed Feb 4, 2015
1 parent 7a43f1d commit 2639414
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/test_sanitize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
@s.document(input)
input.must_equal('<!DOCTYPE html><b>foo</b>')
end

it 'should not choke on frozen documents' do
@s.document('<!doctype html><html><b>foo</b>'.freeze).must_equal "<html>foo</html>\n"
end
end

describe '#fragment' do
Expand All @@ -43,7 +47,7 @@
@s.fragment('<!DOCTYPE html><html><body><b>foo</b></body></html>').must_equal 'foo'
end

it 'should not choke on fragments which are frozen' do
it 'should not choke on frozen fragments' do
@s.fragment('<b>foo</b>'.freeze).must_equal 'foo'
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/test_unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
@s = Sanitize.new(Sanitize::Config::RELAXED)
end

it 'should not modify the input string' do
fragment = "a\u0340b\u0341c"
document = "a\u0340b\u0341c"

@s.document(document)
@s.fragment(fragment)

fragment.must_equal "a\u0340b\u0341c"
document.must_equal "a\u0340b\u0341c"
end

it 'should strip deprecated grave and acute clones' do
@s.document("a\u0340b\u0341c").must_equal "<html><head></head><body>abc</body></html>\n"
@s.fragment("a\u0340b\u0341c").must_equal 'abc'
Expand Down

0 comments on commit 2639414

Please sign in to comment.