diff options
author | Alan Pearce | 2017-06-30 21:34:30 +0200 |
---|---|---|
committer | Alan Pearce | 2017-06-30 21:34:30 +0200 |
commit | d3dfbb13b7037c9382bd8418e475ac4208216f39 (patch) | |
tree | 21a965c1f50e1d98c075b2694bc7dc7fa2b6f97b /test | |
parent | 7d0ca01038f1a31af38ddf7b156da688f62f2f00 (diff) | |
download | homestead-d3dfbb13b7037c9382bd8418e475ac4208216f39.tar.lz homestead-d3dfbb13b7037c9382bd8418e475ac4208216f39.tar.zst homestead-d3dfbb13b7037c9382bd8418e475ac4208216f39.zip |
feat: add basic h-card to homepage header
Diffstat (limited to 'test')
-rw-r--r-- | test/app.test.js | 37 |
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(), |