-
Notifications
You must be signed in to change notification settings - Fork 6
/
entries_test.ts
55 lines (50 loc) · 1.55 KB
/
entries_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
import { getContentEntries, getStaticEntries } from "./entries.ts";
import { defaultBuildConfig } from "./config.ts";
import { assertEquals } from "./deps/std.ts";
const testPath = `${Deno.cwd()}/test/entries/`;
const config = defaultBuildConfig;
Deno.test(
"getContentEntries should return an array of WalkEntry objects",
async () => {
const entries = await getContentEntries({ path: testPath });
assertEquals(Array.isArray(entries) && entries.length > 0, true);
assertEquals(typeof entries[0].path, "string");
}
);
Deno.test(
"getContentEntries should include only directories and markdown files",
async () => {
const entries = await getContentEntries({ path: testPath });
assertEquals(
entries.every((entry) => entry.path.endsWith(".md") || entry.isDirectory),
true
);
}
);
Deno.test(
"getContentEntries should exclude hidden and underscored files",
async () => {
const entries = await getContentEntries({ path: testPath });
assertEquals(
entries.every(
(entry) => !entry.name.startsWith("_") && !entry.name.startsWith(".")
),
true
);
}
);
Deno.test(
"getStaticEntries should return an array of WalkEntry objects with static extensions",
async () => {
const entries = await getStaticEntries({
path: testPath,
exts: config.staticExts,
});
assertEquals(Array.isArray(entries) && entries.length > 0, true);
assertEquals(typeof entries[0].path, "string");
assertEquals(
entries.every((entry) => entry.path.endsWith(".jpg")),
true
);
}
);