feat: add basic h-card to homepage header
1 file changed, 33 insertions(+), 4 deletions(-)
changed files
M test/app.test.js → 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 @@ normalizeWhitespace: true, useHtmlParser2: true }); +const toMicroformatsOptions = node => ({ + node, + textFormat: "normalised" +}); + test("homepage", t => { return request(app.listen()) .get("/")@@ -21,10 +29,31 @@ .expect(200) .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 @@ .expect(200) .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(),