summary refs log tree commit diff stats
path: root/test/domain/posts.test.js
blob: bb97361c589964cf26d601d43b47d108e039f810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const test = require("ava");
const path = require("path");

const Posts = require("../../src/domain/posts.js");

test.beforeEach(async t => {
  t.context = await Posts(
    {
      folder: path.resolve(__dirname, "../testsite/posts/"),
      taxonomies: {
        tag: "tags",
        category: "categories"
      }
    },
    basename => basename
  );
});

test("get", async t => {
  const expected = new Map(
    Object.entries({
      title: "This is a test",
      description: "Test file",
      date: new Date("2017-01-01T00:00:00Z"),
      tags: ["a", "b"]
    })
  );
  const post = await t.context.get(
    basename => basename,
    path.resolve(__dirname, "../testsite/posts/testfile.md")
  );
  t.deepEqual(post.data, expected);
  t.is(post.basename, "testfile", "must include basename");
});