clean up tests · TypeScriptToLua/TypeScriptToLua@1dba060 · GitHub
Skip to content

Commit 1dba060

Browse files
committed
clean up tests
1 parent 7cb97ad commit 1dba060

4 files changed

Lines changed: 33 additions & 27 deletions

File tree

‎test/translation/__snapshots__/transformation.spec.ts.snap‎

Lines changed: 1 addition & 1 deletion

‎test/translation/transformation.spec.ts‎

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,32 @@ import { annotationDeprecated } from "../../src/transformation/utils/diagnostics
55
import { couldNotResolveRequire } from "../../src/transpilation/diagnostics";
66
import * as util from "../util";
77

8-
const targetSpecs: Array<[string, tstl.LuaTarget | undefined, string]> = [
9-
["", undefined, "./transformation"],
10-
["Luau ", tstl.LuaTarget.Luau, "./transformation/luau"],
11-
];
8+
const fixturesPath = path.join(__dirname, "./transformation");
9+
const fixtures = fs
10+
.readdirSync(fixturesPath)
11+
.filter(f => path.extname(f) === ".ts")
12+
.sort()
13+
.map(f => [path.parse(f).name, fs.readFileSync(path.join(fixturesPath, f), "utf8")]);
1214

13-
for (const [name, luaTarget, targetDir] of targetSpecs) {
14-
const fixturesPath = path.join(__dirname, targetDir);
15-
const fixtures = fs
16-
.readdirSync(fixturesPath)
17-
.filter(f => path.extname(f) === ".ts")
18-
.sort()
19-
.map(f => [path.parse(f).name, fs.readFileSync(path.join(fixturesPath, f), "utf8")]);
15+
test.each(fixtures)("Transformation (%s)", (_name, content) => {
16+
util.testModule(content)
17+
.setOptions({ luaLibImport: tstl.LuaLibImportKind.Require })
18+
.ignoreDiagnostics([annotationDeprecated.code, couldNotResolveRequire.code])
19+
.disableSemanticCheck()
20+
.expectLuaToMatchSnapshot();
21+
});
2022

21-
test.each(fixtures)(`${name}Transformation (%s)`, (_name, content) => {
22-
util.testModule(content)
23-
.setOptions({
24-
luaLibImport: tstl.LuaLibImportKind.Require,
25-
luaTarget,
26-
})
27-
.ignoreDiagnostics([annotationDeprecated.code, couldNotResolveRequire.code])
28-
.disableSemanticCheck()
29-
.expectLuaToMatchSnapshot();
30-
});
31-
}
23+
const luauFixturesPath = path.join(fixturesPath, "luau");
24+
const luauFixtures = fs
25+
.readdirSync(luauFixturesPath)
26+
.filter(f => path.extname(f) === ".ts")
27+
.sort()
28+
.map(f => [path.parse(f).name, fs.readFileSync(path.join(luauFixturesPath, f), "utf8")]);
29+
30+
test.each(luauFixtures)("Luau-specific Transformation (%s)", (_name, content) => {
31+
util.testModule(content)
32+
.setOptions({ luaLibImport: tstl.LuaLibImportKind.Require, luaTarget: tstl.LuaTarget.Luau })
33+
.ignoreDiagnostics([annotationDeprecated.code, couldNotResolveRequire.code])
34+
.disableSemanticCheck()
35+
.expectLuaToMatchSnapshot();
36+
});

‎test/unit/builtins/array.spec.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,7 @@ test("new Array()", () => {
907907
const arr = new Array();
908908
arr.push(1,2,3);
909909
return arr;
910-
`
911-
.debug()
912-
.expectToMatchJsResult();
910+
`.expectToMatchJsResult();
913911
});
914912

915913
test("new Array<T>()", () => {

‎test/unit/loops.spec.ts‎

Lines changed: 4 additions & 1 deletion

0 commit comments

Comments
 (0)