summary refs log tree commit diff stats
path: root/test/app.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/app.test.js')
-rw-r--r--test/app.test.js51
1 files changed, 49 insertions, 2 deletions
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 <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 @@ 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, /^<!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);