Testing HTML Content Cleaning Filter in DevDocs
This test suite validates the CleanTextFilter functionality in the DevDocs documentation system, focusing on HTML content cleaning and normalization. The tests ensure proper handling of empty nodes, whitespace management, and preservation of specific HTML elements.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
freecodecamp/devdocs
test/lib/docs/filters/core/clean_text_test.rb
require_relative '../../../../test_helper'
require_relative '../../../../../lib/docs'
class CleanTextFilterTest < Minitest::Spec
include FilterTestHelper
self.filter_class = Docs::CleanTextFilter
it "removes empty nodes" do
@body = "<div class=\"test\"><p data><span> \u00A0</span>\n\r<a></a></p></div>"
assert_empty filter_output
end
it "doesn't remove empty <iframe>, <td>, and <th>" do
@body = "<iframe></iframe><td></td><th></th>"
assert_equal @body, filter_output
end
it "strips leading and trailing whitespace" do
@body = "\n\r Test \r\n"
assert_equal 'Test', filter_output
end
end