Skip to content

Commit

Permalink
chore(satori): add message parse test
Browse files Browse the repository at this point in the history
  • Loading branch information
KurenaiRyu committed May 27, 2024
1 parent a6be8e3 commit baa6e56
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/test/kotlin/JsoupTest.kt
Original file line number Diff line number Diff line change
@@ -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 <img src=\"http://localhost:5500/asset/testid\"/>"

@Test
fun test() {
println(Jsoup.parse(content).body().text())
println(Jsoup.parse(content).body().getElementsByTag("img").attr("src"))
val content = "Test Content with <img src=\"http://localhost:5500/asset/testid\"/>"
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 =
"<quote chronocat:seq=\"524381\"><author id=\"2655297208\" name=\"夏影\" avatar=\"http://thirdqq.qlogo.cn/headimg_dl?dst_uin=2655297208&amp;spec=640\"/>没看gbc台长后面激情输出9分钟</quote><at id=\"2655297208\" name=\"夏影\"/> 快6k评论了<chronocat:face id=\"317\" name=\"[菜汪]\" platform=\"chronocat\"/>"
val doc = Jsoup.parse(content, Parser.xmlParser())
assertTrue(doc.allElements[0].getElementsByTag("author").size > 0)
}
}

0 comments on commit baa6e56

Please sign in to comment.