From a270da04578d6ebadc544d0494e1a711115b04ce Mon Sep 17 00:00:00 2001
From: Marcus Fihlon
Date: Sat, 13 Apr 2024 08:17:02 +0200
Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20tests=20for=20parsing=20and?=
=?UTF-8?q?=20sanitizing=20HTML=20code=20#85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../swiss/fihlon/apus/util/HtmlUtilTest.java | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 src/test/java/swiss/fihlon/apus/util/HtmlUtilTest.java
diff --git a/src/test/java/swiss/fihlon/apus/util/HtmlUtilTest.java b/src/test/java/swiss/fihlon/apus/util/HtmlUtilTest.java
new file mode 100644
index 0000000..aaa95f8
--- /dev/null
+++ b/src/test/java/swiss/fihlon/apus/util/HtmlUtilTest.java
@@ -0,0 +1,58 @@
+/*
+ * Apus - A social wall for conferences with additional features.
+ * Copyright (C) Marcus Fihlon and the individual contributors to Apus.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package swiss.fihlon.apus.util;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class HtmlUtilTest {
+
+ @Test
+ void sanitize() {
+ assertEquals("ABCD
",
+ HtmlUtil.sanitize("ABCD
"));
+ assertEquals("Test",
+ HtmlUtil.sanitize("Test"));
+ assertEquals("Test Test",
+ HtmlUtil.sanitize("Test Test"));
+ assertEquals("Test Test",
+ HtmlUtil.sanitize("Test Test"));
+ assertEquals("Test
",
+ HtmlUtil.sanitize("Test
"));
+ assertEquals("Test >>>Test<<< Test
",
+ HtmlUtil.sanitize("Test
>>>Test<<< Test"));
+ }
+
+ @Test
+ void extractText() {
+ assertEquals("ABCD",
+ HtmlUtil.extractText("
ABCD
"));
+ assertEquals("Test",
+ HtmlUtil.extractText("Test"));
+ assertEquals("Test Test",
+ HtmlUtil.extractText("Test Test"));
+ assertEquals("Test Test",
+ HtmlUtil.extractText("Test Test"));
+ assertEquals("Test",
+ HtmlUtil.extractText("Test
"));
+ assertEquals("Test >>>Test<<< Test",
+ HtmlUtil.extractText("Test >>>Test<<< Test"));
+ }
+
+}