diff --git a/src/test/kotlin/JsoupTest.kt b/src/test/kotlin/JsoupTest.kt index 940f854..cfd4e9e 100644 --- a/src/test/kotlin/JsoupTest.kt +++ b/src/test/kotlin/JsoupTest.kt @@ -1,13 +1,24 @@ import org.jsoup.Jsoup +import org.jsoup.parser.Parser +import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test class JsoupTest { - private val content = "Test Content with " @Test fun test() { - println(Jsoup.parse(content).body().text()) - println(Jsoup.parse(content).body().getElementsByTag("img").attr("src")) + val content = "Test Content with " + val doc = Jsoup.parse(content, Parser.xmlParser()) + assertEquals("Test Content with ", doc.childNodes()[0].toString()) + assertEquals("http://localhost:5500/asset/testid", doc.getElementsByTag("img").attr("src")) + } + + @Test + fun testMultiTags() { + val content = + "没看gbc台长后面激情输出9分钟 快6k评论了" + val doc = Jsoup.parse(content, Parser.xmlParser()) + assertTrue(doc.allElements[0].getElementsByTag("author").size > 0) } } \ No newline at end of file