Skip to content

Commit

Permalink
test: let's add coverage for the doctype rename workaround
Browse files Browse the repository at this point in the history
I want to make sure that we don't break the thing we're asking
Sanitize to do; and I want to make sure we have valgrind coverage for it.

See rgrove/sanitize#238 for context.
  • Loading branch information
flavorjones committed Jun 12, 2024
1 parent 272b45c commit 7b713b9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/xml/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ def test_create_internal_subset
assert_equal("staff.dtd", ss.system_id)
end

def test_replacing_internal_subset
# see https://github.com/rgrove/sanitize/pull/238
skip_unless_libxml2("JRuby impl does not support unlinking the internal subset, it probably should")

document = Nokogiri::HTML5::Document.parse("<!DOCTYPE foo><html><div>hello</div></html>")

assert_equal("foo", document.internal_subset.name)

document.internal_subset.unlink
document.create_internal_subset("bar", nil, nil)

assert_equal("bar", document.internal_subset.name)
assert_operator(document.to_html, :start_with?, "<!DOCTYPE bar>")
end

def test_external_subset
assert_nil(xml.external_subset)
xml = Dir.chdir(ASSETS_DIR) do
Expand Down

0 comments on commit 7b713b9

Please sign in to comment.