Beispiel #1
0
func checkCommentsSection(t T, node *html.Node) {
	noComments := htmltest.CssSelect(t.T, node, "p")
	comments := htmltest.CssSelect(t.T, node, "strong")
	t.failIf(len(noComments) == 0 && len(comments) == 0,
		"Comments node not found in section: %q", h5.NewTree(node).String())
	if len(comments) > 0 {
		headers := htmltest.CssSelect(t.T, node, ".comment-container")
		t.failIf(len(headers) == 0,
			"Comment header not found in section: %q", h5.NewTree(node).String())
		bodies := htmltest.CssSelect(t.T, node, ".bubble-container")
		t.failIf(len(bodies) == 0,
			"Comment body not found in section: %q", h5.NewTree(node).String())
	}
}
Beispiel #2
0
func checkTagsSection(t T, node *html.Node) {
	if strings.Contains(h5.NewTree(node).String(), " ") {
		return
	}
	n2 := htmltest.CssSelect(t.T, node, "a")
	t.failIf(len(n2) == 0, "Tags node not found in section: %q", h5.NewTree(node).String())
}
Beispiel #3
0
func checkAuthorSection(t T, node *html.Node) {
	date := node.FirstChild.Data
	dateRe, _ := regexp.Compile("[0-9]{4}-[0-9]{2}-[0-9]{2}")
	m := dateRe.FindString(date)
	t.failIf(m == "", "No date found in author section!")
	n2 := htmltest.CssSelect(t.T, node, "strong")
	t.failIf(len(n2) != 1, "Author node not found in section: %q", h5.NewTree(node).String())
	t.failIf(h5.Children(n2[0]) == nil, "Author node not found in section: %q", h5.NewTree(node).String())
}