deno.land / x / lume@v2.1.4 / tests / fff.test.ts

نووسراو ببینە
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { assertEquals } from "../deps/assert.ts";import { assertSiteSnapshot, build, getSite } from "./utils.ts";import fff from "../plugins/fff.ts";
Deno.test("FFF plugin", async (t) => { const site = getSite({ src: "fff", location: new URL("https://example.com/"), });
site.use(fff({ date: "published", presets: [{ summary: "content", }], strict: { categories: false, media: { array: false, type: "object", }, }, getGitDate: true, postTypeDiscovery: true, }));
// build page await build(site);
// compare to snapshot await assertSiteSnapshot(t, site);
const { pages } = site;
// published => date const date = pages.find((page) => page.src.path === "/date")!; assertEquals(date.data.date, date.data.published); // getGitDate assertEquals(!!date.data.created, true); assertEquals(!!date.data.updated, true); // postTypeDiscovery assertEquals(date.data.type, "article");
// images (string media) => image (object media) const image = pages.find((page) => page.src.path === "/image")!; assertEquals(image.data.image.alt, "FFF Image Test"); assertEquals(image.data.image.src, "/my-image.png"); // getGitDate assertEquals(!!image.data.created, true); assertEquals(!!image.data.updated, true); // postTypeDiscovery assertEquals(image.data.type, "photo");
// categories => tags const tags = pages.find((page) => page.src.path === "/tags")!; assertEquals(tags.data.tags, ["foo", "bar", "baz", "qux"]); // getGitDate assertEquals(!!tags.data.created, true); assertEquals(!!tags.data.updated, true); // postTypeDiscovery (todo: fix this) // assertEquals(tags.data.type, "note");});
lume

Version Info

Tagged at
7 months ago