From 07e89a5794b882c82f3d0fea39252e56948936e7 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 17 Jan 2021 12:50:54 -0500 Subject: [PATCH] test: extend Nokogiri decorator tests to NodeSets --- test/unit/test_api.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/test_api.rb b/test/unit/test_api.rb index 00b0cb67..97e3eb4c 100644 --- a/test/unit/test_api.rb +++ b/test/unit/test_api.rb @@ -55,6 +55,13 @@ class UnitTestApi < Loofah::TestCase node_set.scrub!(:strip) end + it "scrubs fragment nodesets" do + doc = Loofah.fragment(HTML) + assert(node_set = doc.css("div")) + assert_instance_of Nokogiri::XML::NodeSet, node_set + node_set.scrub!(:strip) + end + it "exposes serialize_root on HTML::DocumentFragment" do doc = Loofah.fragment(HTML) assert_equal HTML, doc.serialize_root.to_html @@ -110,6 +117,13 @@ class UnitTestApi < Loofah::TestCase assert(node = doc.at_css("div")) node.scrub!(:strip) end + + it "scrubs document nodesets" do + doc = Loofah.xml_document(XML) + assert(node_set = doc.css("div")) + assert_instance_of Nokogiri::XML::NodeSet, node_set + node_set.scrub!(:strip) + end end private