aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/base-test-utils
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/base-test-utils')
-rw-r--r--plugins/base/base-test-utils/build.gradle.kts1
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt18
2 files changed, 19 insertions, 0 deletions
diff --git a/plugins/base/base-test-utils/build.gradle.kts b/plugins/base/base-test-utils/build.gradle.kts
index 1de0ac0f..5515c965 100644
--- a/plugins/base/base-test-utils/build.gradle.kts
+++ b/plugins/base/base-test-utils/build.gradle.kts
@@ -2,4 +2,5 @@ dependencies {
compileOnly(project(":plugins:base"))
implementation(project(":core:test-api"))
implementation("org.jsoup:jsoup:1.12.1")
+ implementation(kotlin("test-junit"))
}
diff --git a/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt b/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt
new file mode 100644
index 00000000..f8ef8a41
--- /dev/null
+++ b/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt
@@ -0,0 +1,18 @@
+package utils
+
+import junit.framework.Assert.assertEquals
+import org.jsoup.Jsoup
+
+/**
+ * Parses it using JSOUP, trims whitespace at the end of the line and asserts if they are equal
+ * parsing is required to unify the formatting
+ */
+fun assertHtmlEqualsIgnoringWhitespace(expected: String, actual: String) {
+ assertEquals(
+ Jsoup.parse(expected).outerHtml().trimSpacesAtTheEndOfLine(),
+ Jsoup.parse(actual).outerHtml().trimSpacesAtTheEndOfLine()
+ )
+}
+
+private fun String.trimSpacesAtTheEndOfLine(): String =
+ replace(" \n", "\n") \ No newline at end of file