package parser import ( "strings" "testing" ) func TestParseDraftJSText(t *testing.T) { desc := `就这样吧评论: 奥德赛 (https://movie.douban.com/subject/36808876/) 评价: 推荐 {"entityMap": {}, "blocks": [{"key": "1", "text": "终于看完了奥德赛,非常精彩!", "type": "unstyled"}]}` content := `就这样吧评论: 奥德赛
评价: 推荐` combined := sanitizeAndCombineContent(content, desc) if !strings.Contains(combined, "终于看完了奥德赛,非常精彩!") { t.Fatalf("expected parsed text in output, got: %s", combined) } if !strings.Contains(combined, "

终于看完了奥德赛,非常精彩!

") { t.Fatalf("expected formatted paragraph in output, got: %s", combined) } if !strings.Contains(combined, "img9.doubanio.com/poster.jpg") { t.Fatalf("expected poster in output, got: %s", combined) } }