From d3dfbb13b7037c9382bd8418e475ac4208216f39 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 30 Jun 2017 21:34:30 +0200 Subject: feat: add basic h-card to homepage header --- test/app.test.js | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'test/app.test.js') 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(/^/) .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(/^/) .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(), -- cgit 1.4.1