diff --git a/src/test/java/stirling/software/SPDF/utils/CustomHtmlSanitizerTest.java b/src/test/java/stirling/software/SPDF/utils/CustomHtmlSanitizerTest.java index 348ad1029..ad403331a 100644 --- a/src/test/java/stirling/software/SPDF/utils/CustomHtmlSanitizerTest.java +++ b/src/test/java/stirling/software/SPDF/utils/CustomHtmlSanitizerTest.java @@ -8,62 +8,39 @@ import org.junit.jupiter.api.Test; class CustomHtmlSanitizerTest { - @Test - void testSanitizeAllowsValidHtml() { - // Arrange - String validHtml = "
This is valid HTML with formatting.
"; - + @ParameterizedTest + @MethodSource("provideHtmlTestCases") + void testSanitizeHtml(String inputHtml, String[] expectedContainedTags) { // Act - String sanitizedHtml = CustomHtmlSanitizer.sanitize(validHtml); + String sanitizedHtml = CustomHtmlSanitizer.sanitize(inputHtml); // Assert - assertEquals(validHtml, sanitizedHtml); + for (String tag : expectedContainedTags) { + assertTrue(sanitizedHtml.contains(tag), tag + " should be preserved"); + } } - @Test - void testSanitizeAllowsFormattingElements() { - // Arrange - Testing Sanitizers.FORMATTING - String htmlWithFormatting = + private static StreamThis is valid HTML with formatting.
", + new String[] {"", "", ""}
+ ),
+ Arguments.of(
" Text with bold, italic, underline, "
+ "emphasis, strong, strikethrough, "
+ "strike, subscript, superscript, "
- + "teletype, code
, big, small.code
, big, small.
Blockquote
"), "Blockquote tags should be preserved"); - assertTrue(sanitizedHtml.contains(""), "UL tags should be preserved"); - assertTrue(sanitizedHtml.contains("
"), "OL tags should be preserved"); - assertTrue(sanitizedHtml.contains("
- "), "LI tags should be preserved"); + + "
", + new String[] {"
- Ordered item
", "", "
", "
", "", "
", "
- "} + ) + ); } @Test