Esempio n. 1
0
func TestArchiveContainsAllEntries(t *testing.T) {
	if len(testPosts) <= NumRecentPosts {
		t.Fatalf("This test only makes sense if len(testPosts) > NUM_RECENT_POSTS")
	}
	nodes := htmltest.Query(t, "archive", "*", ".post-title")
	require.Len(t, nodes, len(testPosts), "Not all posts rendered in archive!")
}
Esempio n. 2
0
func TestEntriesHaveTagsInList(t *testing.T) {
	nodes := htmltest.Query(t, "", "+", ".tags")
	for _, node := range nodes {
		assertElem(t, node, "div")
		require.NotEmpty(t, h5.Children(node), "Empty tags div!")
		checkTagsSection(T{t}, node)
	}
}
Esempio n. 3
0
func TestEntryListHasAuthor(t *testing.T) {
	nodes := htmltest.Query(t, "", "+", ".author")
	for _, node := range nodes {
		assertElem(t, node, "div")
		require.NotEmpty(t, h5.Children(node), "Empty author div!")
		checkAuthorSection(T{t}, node)
	}
}
Esempio n. 4
0
func TestAllCommentsPageHasAllComments(t *testing.T) {
	defer testData.reset()
	ensureLogin()
	nodes := htmltest.Query(t, "/all_comments", "+", "#comment")
	if len(nodes) != len(testComm) {
		t.Fatalf("Not all comments in /all_comments!")
	}
	testData.expect(t, (*TestData).allComments, "")
}
Esempio n. 5
0
func TestCommentsFormattingInPostPage(t *testing.T) {
	for _, p := range testPosts {
		nodes := htmltest.Query(t, p.URL, "*", "#comments")
		require.Len(t, nodes, 1, "There should be only one comments section!")
		for _, node := range nodes {
			assertElem(t, node, "div")
			require.False(t, emptyChildren(node), "Empty comments div found!")
			checkCommentsSection(T{t}, node)
		}
	}
}
Esempio n. 6
0
func TestPagination(t *testing.T) {
	nodes := htmltest.Query(t, "page/2", "*", ".post-title")
	T{t}.failIf(len(nodes) != PostsPerPage, "Not all posts have been rendered!")
	if nodes[0].Attr[1].Val != "/hello6" {
		t.Fatalf("Wrong post!")
	}
	if nodes[4].Attr[1].Val != "/hello10" {
		t.Fatalf("Wrong post!")
	}
	html := htmltest.Curl("page/2")
	mustContain(t, html, "<a href=\"/page/1\">1</a>\n2\n<a href=\"/page/3\">3</a>\n")
}
Esempio n. 7
0
func TestTagFormattingInPostPage(t *testing.T) {
	for _, e := range testPosts {
		nodes := htmltest.Query(t, e.URL, "*", ".tags")
		if len(nodes) > 0 {
			for _, node := range nodes {
				assertElem(t, node, "div")
				require.NotEmpty(t, h5.Children(node), "Empty tags div!")
				checkTagsSection(T{t}, node)
			}
		}
	}
}
Esempio n. 8
0
func TestMainPageHasEditPostButtonWhenLoggedIn(t *testing.T) {
	ensureLogin()
	nodes := htmltest.Query(t, "", "+", ".edit-post-button")
	require.Len(t, nodes, PostsPerPage, "Not all posts have Edit button!")
}
Esempio n. 9
0
func TestOnlyOnePageOfPostsAppearsOnMainPage(t *testing.T) {
	nodes := htmltest.Query(t, "", "*", ".post-title")
	require.Len(t, nodes, PostsPerPage, "Not all posts have been rendered!")
}