From 529946dc5bdccc2153c97e2040953047319480f4 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 3 Oct 2017 17:28:29 +0200 Subject: Add tags listing --- test/app.test.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'test/app.test.js') diff --git a/test/app.test.js b/test/app.test.js index 33c8905..a3f06a1 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -45,8 +45,20 @@ test("homepage", async function(t) { t.is($("head > title").text(), "John Doe", "head title is site author"); t.is($("main").length, 1, "only one
tag"); - t.is($("nav a").first().text(), "Home", "nav link has text"); - t.is($("nav a").first().attr("href"), "/", "nav links to homepage"); + t.is( + $("nav a") + .first() + .text(), + "Home", + "nav link has text" + ); + t.is( + $("nav a") + .first() + .attr("href"), + "/", + "nav links to homepage" + ); t.is( $("a[rel=me]").length, 2, @@ -131,6 +143,41 @@ test("post", async function(t) { }); test("tags", async function(t) { + const res = await request(app.listen()).get("/tag"); + + t.is(res.statusCode, 200); + t.is(res.type, "text/html"); + t.is(res.charset, "utf-8"); + t.regex(res.text, /^/); + + const $ = parseResponse(res); + + t.is( + $("head > title").text(), + "Tags ยท John Doe", + "head title contains 'Tags' and site name" + ); + + t.is($(".tags > .tag").length, 2, "lists two tags"); + + t.is( + $(".tag .p-name") + .first() + .text(), + "A", + "sets tag text" + ); + + t.is( + $(".tag .u-url") + .first() + .attr("href"), + "/tag/a", + "sets tag link" + ); +}); + +test("tag", async function(t) { const res = await request(app.listen()).get("/tag/a"); t.is(res.statusCode, 200); -- cgit 1.4.1