all repos โ€” archive/homestead @ 529946dc5bdccc2153c97e2040953047319480f4

My future indieweb platform

Add tags listing

Alan Pearce
commit

529946dc5bdccc2153c97e2040953047319480f4

parent

ad56116d0df26b4a6fe7f9cd04a21965d3184af5

1 file changed, 49 insertions(+), 2 deletions(-)

changed files
M test/app.test.js โ†’ test/app.test.js
@@ -45,8 +45,20 @@ const $ = parseResponse(res);
t.is($("head > title").text(), "John Doe", "head title is site author"); t.is($("main").length, 1, "only one <main> 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 @@ t.snapshot(data, "should contain relevant microformats data");
}); 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, /^<!DOCTYPE html>/); + + 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);