-
-
Notifications
You must be signed in to change notification settings - Fork 512
/
Copy pathEleventyServeTest.js
78 lines (59 loc) · 1.72 KB
/
EleventyServeTest.js
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
68
69
70
71
72
73
74
75
76
77
78
import test from "ava";
import EleventyServe from "../src/EleventyServe.js";
import TemplateConfig from "../src/TemplateConfig.js";
async function getServerInstance(eleventyConfig) {
let es = new EleventyServe();
if (!eleventyConfig) {
eleventyConfig = new TemplateConfig();
await eleventyConfig.init();
}
es.eleventyConfig = eleventyConfig;
await es.init();
delete es.options.logger;
delete es.options.module;
return es;
}
test("Constructor", async (t) => {
let es = await getServerInstance();
t.is(es.options.pathPrefix, "/");
});
test("Get Options", async (t) => {
let es = await getServerInstance();
es.setOutputDir("_site");
t.deepEqual(es.options, {
pathPrefix: "/",
port: 8080,
});
});
test("Get Options (with a pathPrefix)", async (t) => {
let eleventyConfig = new TemplateConfig();
await eleventyConfig.init({ pathPrefix: "/web/" });
let es = await getServerInstance(eleventyConfig);
es.setOutputDir("_site");
t.deepEqual(es.options, {
pathPrefix: "/web/",
port: 8080,
});
});
test("Get Options (override in config)", async (t) => {
let es = await getServerInstance();
es.setOutputDir("_site");
t.deepEqual(es.options, {
pathPrefix: "/",
port: 8080,
});
});
test("Sanity test that default output is set correctly", async (t) => {
let es = await getServerInstance();
es.setOutputDir("_site");
await es.initServerInstance();
t.is(es.server.dir, "_site");
});
// This assert should work once updating the output dir of the server works.
test("Custom output dir is set correctly", async (t) => {
let es = await getServerInstance();
es.setOutputDir("x");
await es.initServerInstance();
t.is(es.outputDir, "x");
t.is(es.server.dir, "x");
});