Add tests for Konsumer.nullableTextRecursively()

This commit is contained in:
Shinokuni 2020-09-30 18:10:18 +02:00
parent 872a894db0
commit 6f2ff36ece
1 changed files with 26 additions and 0 deletions

View File

@ -58,4 +58,30 @@ description
assertEquals(description, "description")
}
}
@Test
fun nullableTextRecursivelyNullCaseTest() {
val xml = """
<description></description>
""".trimIndent()
xml.konsumeXml().apply {
val description = child("description") { nullableTextRecursively() }
assertNull(description)
}
}
@Test
fun nullableTextRecursivelyNonNullCaseTest() {
val xml = """
<description>
descrip<a>tion</a>
</description>
""".trimIndent()
xml.konsumeXml().apply {
val description = child("description") { nullableTextRecursively() }
assertEquals(description, "description")
}
}
}