-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(satori): add message parse test
- Loading branch information
1 parent
a6be8e3
commit baa6e56
Showing
1 changed file
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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&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) | ||
} | ||
} |