-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.test.js
29 lines (25 loc) · 964 Bytes
/
index.test.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
const { main } = require("./index");
const sh = require("shelljs");
const fs = require("fs");
const semver = require("semver");
describe("main", () => {
const tsVersions = ["3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6", "4.7"];
if (fs.existsSync(`baselines/local`)) {
sh.rm("-r", `baselines/local`);
}
for (const tsVersion of tsVersions) {
test(
"downlevel TS to " + tsVersion,
() => {
main("test", `baselines/local/ts${tsVersion}`, semver.coerce(tsVersion));
expect(fs.readFileSync(`baselines/local/ts${tsVersion}/test.d.ts`, "utf8")).toEqual(
fs.readFileSync(`baselines/reference/ts${tsVersion}/test.d.ts`, "utf8")
);
expect(fs.readFileSync(`baselines/local/ts${tsVersion}/src/test.d.ts`, "utf8")).toEqual(
fs.readFileSync(`baselines/reference/ts${tsVersion}/src/test.d.ts`, "utf8")
);
},
10 * 1000
);
}
});