-
Notifications
You must be signed in to change notification settings - Fork 679
/
converter.test.ts
89 lines (80 loc) · 2.8 KB
/
converter.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { deepStrictEqual as equal, ok } from "assert";
import * as FS from "fs";
import * as Path from "path";
import { ProjectReflection, resetReflectionID } from "..";
import { getExpandedEntryPointsForPaths } from "../lib/utils";
import {
getConverterApp,
getConverterBase,
getConverterProgram,
} from "./programs";
describe("Converter", function () {
const base = getConverterBase();
const app = getConverterApp();
it("Compiles", () => {
getConverterProgram();
});
const checks: [string, () => void, () => void][] = [
[
"specs",
() => {
// nop
},
() => {
// nop
},
],
[
"specs-with-lump-categories",
() => app.options.setValue("categorizeByGroup", false),
() => app.options.setValue("categorizeByGroup", true),
],
[
"specs.nodoc",
() => app.options.setValue("excludeNotDocumented", true),
() => app.options.setValue("excludeNotDocumented", false),
],
];
FS.readdirSync(base).forEach(function (directory) {
const path = Path.join(base, directory);
if (!FS.lstatSync(path).isDirectory()) {
return;
}
describe(directory, function () {
for (const [file, before, after] of checks) {
const specsFile = Path.join(path, `${file}.json`);
if (!FS.existsSync(specsFile)) {
continue;
}
let result: ProjectReflection | undefined;
it(`[${file}] converts fixtures`, function () {
before();
resetReflectionID();
const entryPoints = getExpandedEntryPointsForPaths(
app.logger,
[path],
app.options,
[getConverterProgram()]
);
ok(entryPoints, "Failed to get entry points");
result = app.converter.convert(entryPoints);
after();
ok(
result instanceof ProjectReflection,
"No reflection returned"
);
});
it(`[${file}] matches specs`, function () {
const specs = JSON.parse(
FS.readFileSync(specsFile, "utf-8")
);
// Pass data through a parse/stringify to get rid of undefined properties
const data = JSON.parse(
JSON.stringify(app.serializer.toObject(result))
);
equal(data, specs);
});
}
});
});
});