From 9d601e206bdad2c384f2328a14fea8c0f5428ca9 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 4 Jul 2017 21:03:24 +0200 Subject: feat: Add posts listing --- test/app.test.js | 31 ++++++++++++++++++ test/snapshots/app.test.js.md | 68 +++++++++++++++++++++++++++++++++++++++- test/snapshots/app.test.js.snap | Bin 1550 -> 1658 bytes 3 files changed, 98 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/app.test.js b/test/app.test.js index ac0ce2d..1f8e72f 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -63,6 +63,37 @@ test("homepage", async function(t) { t.snapshot(data, "should contain relevant microformats data"); }); +test("posts", async function(t) { + const res = await request(app.listen()).get("/post/"); + + t.is(res.statusCode, 200); + t.is(res.type, "text/html"); + t.is(res.charset, "utf-8"); + t.regex(res.text, /^/); + + const $ = parseResponse(res); + + t.is( + $("head > title").text(), + "Posts · " + "John Doe", + "head title contains 'Posts' and site author" + ); + + const options = toMicroformatsOptions($); + const count = await mf.countAsync(options); + + t.deepEqual(count, { + "h-card": 1, + "h-feed": 1, + "h-entry": 1, + rels: 1 + }); + + const data = await mf.getAsync(options); + + t.snapshot(data, "should contain relevant microformats data"); +}); + test("post", async function(t) { const res = await request(app.listen()).get("/post/testfile"); diff --git a/test/snapshots/app.test.js.md b/test/snapshots/app.test.js.md index a595585..02eac70 100644 --- a/test/snapshots/app.test.js.md +++ b/test/snapshots/app.test.js.md @@ -190,4 +190,70 @@ Generated by [AVA](https://ava.li). '/css/code.css', ], }, - } + + +## posts + +> should contain relevant microformats data + + { + items: [ + { + properties: { + name: [ + 'John Doe', + ], + photo: [ + '/static/johndoe.jpg', + ], + url: [ + '/', + ], + }, + type: [ + 'h-card', + ], + }, + { + children: [ + { + properties: { + name: [ + 'This is a test', + ], + published: [ + '2017-01-01T00:00:00.000Z', + ], + url: [ + '/post/testfile', + ], + }, + type: [ + 'h-entry', + ], + value: 'This is a test Sunday, January 1, 2017', + }, + ], + properties: { + name: [ + 'Posts · John Doe', + ], + }, + type: [ + 'h-feed', + ], + }, + ], + 'rel-urls': { + '/css/code.css': { + rels: [ + 'stylesheet', + ], + }, + }, + rels: { + stylesheet: [ + '/css/code.css', + ], + }, + } \ No newline at end of file diff --git a/test/snapshots/app.test.js.snap b/test/snapshots/app.test.js.snap index e356c77..b7ca373 100644 Binary files a/test/snapshots/app.test.js.snap and b/test/snapshots/app.test.js.snap differ -- cgit 1.4.1