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.js37
1 files changed, 33 insertions, 4 deletions
diff --git a/test/app.test.js b/test/app.test.js
index b2f91d1..74aeac5 100644
--- a/test/app.test.js
+++ b/test/app.test.js
@@ -1,7 +1,10 @@
+"use strict";
+
 const test = require("ava");
 const path = require("path");
 const request = require("supertest");
 const cheerio = require("cheerio");
+const mf = require("microformat-node");
 
 process.chdir(path.resolve(__dirname, "./testsite/"));
 const config = require(path.resolve(__dirname, "../src/modules/config.js"));
@@ -14,6 +17,11 @@ const parseResponse = res =>
     useHtmlParser2: true
   });
 
+const toMicroformatsOptions = node => ({
+  node,
+  textFormat: "normalised"
+});
+
 test("homepage", t => {
   return request(app.listen())
     .get("/")
@@ -21,10 +29,31 @@ test("homepage", t => {
     .expect(/^<!DOCTYPE html>/)
     .then(parseResponse)
     .then($ => {
-      t.is($("head > title").text(), config.site.title);
-      t.is($("h1").text(), config.site.title);
+      t.is($("head > title").text(), "John Doe");
+      t.is($("h1").text(), "John Doe");
       t.is($("main").length, 1);
-    });
+      return $;
+    })
+    .then(toMicroformatsOptions)
+    .then(options =>
+      Promise.all([
+        mf.countAsync(options).then(count =>
+          t.deepEqual(count, {
+            "h-card": 1
+          })
+        ),
+        mf.getAsync(options).then(data => {
+          t.deepEqual(data.items, [
+            {
+              properties: {
+                name: ["John Doe"]
+              },
+              type: ["h-card"]
+            }
+          ]);
+        })
+      ])
+    );
 });
 
 test("post", t => {
@@ -34,7 +63,7 @@ test("post", t => {
     .expect(/^<!DOCTYPE html>/)
     .then(parseResponse)
     .then($ => {
-      t.is($("head > title").text(), "This is a test · " + config.site.title);
+      t.is($("head > title").text(), "This is a test · " + "John Doe");
       t.is($("article h1").text(), "This is a test");
       t.is(
         $("article p").text(),