-
Notifications
You must be signed in to change notification settings - Fork 431
Expand file tree
/
Copy pathtemplate.test.ts
More file actions
87 lines (79 loc) · 2.41 KB
/
template.test.ts
File metadata and controls
87 lines (79 loc) · 2.41 KB
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
79
80
81
82
83
84
85
86
87
import { testQuartoCmd } from "../../test.ts";
import { directoryContainsOnlyAllowedPaths, fileExists, noErrorsOrWarnings, printsMessage } from "../../verify.ts";
import { join } from "../../../src/deno_ral/path.ts";
import { ensureDirSync } from "../../../src/deno_ral/fs.ts";
const tempDir = Deno.makeTempDirSync();
for (const ext of ["jasa", "acm"]) {
const templateFolder = `${ext}-article`;
const workingDir = join(tempDir, templateFolder);
const extensionYml = join(workingDir, "_extensions", "quarto-journals", ext, "_extension.yml");
ensureDirSync(workingDir);
testQuartoCmd(
"use",
["template", `quarto-journals/${ext}`, "--no-prompt"],
[noErrorsOrWarnings, fileExists(`${templateFolder}.qmd`), fileExists(extensionYml)],
{
setup: () => {
return Promise.resolve();
},
cwd: () => {
return workingDir;
},
teardown: () => {
try {
Deno.removeSync(workingDir, {recursive: true});
} catch {
}
return Promise.resolve();
}
}
)
}
const nonEmptyTemplateFolder = "notempty";
const nonEmptyFileName = `${nonEmptyTemplateFolder}.qmd`;
const nonEmptyWorkingDir = join(tempDir, nonEmptyTemplateFolder);
ensureDirSync(nonEmptyWorkingDir);
testQuartoCmd(
"use",
["template", "quarto-journals/jasa", "--no-prompt"],
[printsMessage({level: "ERROR", regex: /directory isn't empty/}), directoryContainsOnlyAllowedPaths(nonEmptyWorkingDir, [nonEmptyFileName])],
{
setup: () => {
Deno.writeTextFileSync(join(nonEmptyWorkingDir, nonEmptyFileName), "Just making a non-empty file!");
return Promise.resolve();
},
cwd: () => {
return nonEmptyWorkingDir;
},
teardown: () => {
try {
Deno.removeSync(nonEmptyWorkingDir, {recursive: true});
} catch {
}
return Promise.resolve();
}
}
)
const starterFolder = "starterFolder";
const starterWorkingDir = join(tempDir, starterFolder);
ensureDirSync(starterWorkingDir);
testQuartoCmd(
"use",
["template", "quarto-examples/website-template", "--no-prompt"],
[noErrorsOrWarnings, fileExists("_quarto.yml"), fileExists("index.qmd")],
{
setup: () => {
return Promise.resolve();
},
cwd: () => {
return starterWorkingDir;
},
teardown: () => {
try {
Deno.removeSync(starterWorkingDir, {recursive: true});
} catch {
}
return Promise.resolve();
}
}
)