package web
import "testing"
func TestParagraphsKeepListItemsApart(t *testing.T) {
body := "Bound the walks.\n\n- chainEnd stops at\n the root\n- verifyFrom checks\n\n1. one\n2) two\n\nplain\nwrapped"
got := paragraphs("r", body)
if len(got) != 4 {
t.Fatalf("blocks = %d, want 4: %+v", len(got), got)
}
if got[0].Items != nil || got[0].Text == "" {
t.Errorf("block 0 should be a paragraph: %+v", got[0])
}
if len(got[1].Items) != 2 || got[1].Ordered {
t.Errorf("block 1 should be a two-item bullet list: %+v", got[1])
}
if got[1].Items[0] != commentHTML("r", "chainEnd stops at the root") {
t.Errorf("continuation line should join its item: %q", got[1].Items[0])
}
if len(got[2].Items) != 2 || !got[2].Ordered {
t.Errorf("block 2 should be a two-item numbered list: %+v", got[2])
}
if got[3].Items != nil || got[3].Text != commentHTML("r", "plain wrapped") {
t.Errorf("block 3 should reflow as a paragraph: %+v", got[3])
}
}
func TestParagraphsTextBeforeAListIsItsOwnParagraph(t *testing.T) {
got := paragraphs("r", "Changes:\n- a\n- b")
if len(got) != 2 || got[0].Items != nil || len(got[1].Items) != 2 {
t.Fatalf("want a paragraph then a list: %+v", got)
}
}