deno.land / x / lume@v2.1.4 / tests / build.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
64
65
66
67
import { assertEquals, assertStrictEquals as equals } from "../deps/assert.ts";import { assertSiteSnapshot, build, getSite } from "./utils.ts";
import type { SiteEvent } from "../core/site.ts";
Deno.test("build a simple site", async (t) => { const site = getSite({ src: "simple", });
// Add a page dynamically site.page({ url: "/dynamic.html", title: "Page 1", templateEngine: "vto", content: "Content of {{ title }}", });
await build(site); await assertSiteSnapshot(t, site);
// Test the enumerated properties const page = site.pages[0]; assertEquals(Object.keys(page), ["src", "data"]);});
Deno.test("build/update events", async () => { const site = getSite( { src: "empty", }, {}, );
const events: string[] = [];
const listener = (event: SiteEvent) => events.push(event.type); const updateListener = (event: SiteEvent<"beforeUpdate" | "afterUpdate">) => { equals(event.files!.size, 1); equals(event.files!.has("/page1.md"), true); listener(event); };
site.addEventListener("beforeBuild", listener); site.addEventListener("afterBuild", listener); site.addEventListener("beforeUpdate", updateListener); site.addEventListener("afterUpdate", updateListener); site.addEventListener("beforeSave", listener); site.addEventListener("afterRender", listener);
await site.build();
equals(events.length, 4); equals(events[0], "beforeBuild"); equals(events[1], "afterRender"); equals(events[2], "beforeSave"); equals(events[3], "afterBuild");
await site.update(new Set(["/page1.md"]));
equals(events.length, 8); equals(events[4], "beforeUpdate"); equals(events[5], "afterRender"); equals(events[6], "beforeSave"); equals(events[7], "afterUpdate");});
lume

Version Info

Tagged at
7 months ago