Skip to content

Commit fbb9f23

Browse files
committed
Remove baseUrl tests
It's not supposed to change runtime behavior by default, and should get the same treatment as `"paths"` (#591).
1 parent 1252265 commit fbb9f23

File tree

6 files changed

+33
-47
lines changed

6 files changed

+33
-47
lines changed

test/transpile/__fixtures__/directories/baseurl/src/lib/nested/file.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/transpile/__fixtures__/directories/baseurl/src/main.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/transpile/__fixtures__/directories/basic/src/lib/file.ts renamed to test/transpile/__fixtures__/directories/src/lib/file.ts

File renamed without changes.

test/transpile/__fixtures__/directories/basic/src/main.ts renamed to test/transpile/__fixtures__/directories/src/main.ts

File renamed without changes.
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`should be able to resolve ({"name": "basic", "options": [Object]}) 1`] = `
3+
exports[`should be able to resolve ({"outDir": "out", "rootDir": "src"}) 1`] = `
44
Array [
5-
"directories/basic/src/lib/file.lua",
6-
"directories/basic/src/lualib_bundle.lua",
7-
"directories/basic/src/main.lua",
5+
"directories/out/lib/file.lua",
6+
"directories/out/lualib_bundle.lua",
7+
"directories/out/main.lua",
88
]
99
`;
1010

11-
exports[`should be able to resolve ({"name": "basic", "options": [Object]}) 2`] = `
11+
exports[`should be able to resolve ({"outDir": "out"}) 1`] = `
1212
Array [
13-
"directories/basic/out/lib/file.lua",
14-
"directories/basic/out/lualib_bundle.lua",
15-
"directories/basic/out/main.lua",
13+
"directories/out/lib/file.lua",
14+
"directories/out/lualib_bundle.lua",
15+
"directories/out/main.lua",
1616
]
1717
`;
1818

19-
exports[`should be able to resolve ({"name": "basic", "options": [Object]}) 3`] = `
19+
exports[`should be able to resolve ({"rootDir": "src"}) 1`] = `
2020
Array [
21-
"directories/basic/src/lib/file.lua",
22-
"directories/basic/src/lualib_bundle.lua",
23-
"directories/basic/src/main.lua",
21+
"directories/src/lib/file.lua",
22+
"directories/src/lualib_bundle.lua",
23+
"directories/src/main.lua",
2424
]
2525
`;
2626

27-
exports[`should be able to resolve ({"name": "basic", "options": [Object]}) 4`] = `
27+
exports[`should be able to resolve ({}) 1`] = `
2828
Array [
29-
"directories/basic/out/lib/file.lua",
30-
"directories/basic/out/lualib_bundle.lua",
31-
"directories/basic/out/main.lua",
29+
"directories/src/lib/file.lua",
30+
"directories/src/lualib_bundle.lua",
31+
"directories/src/main.lua",
3232
]
3333
`;

test/transpile/directories.spec.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,23 @@ import * as ts from "typescript";
22
import * as tstl from "../../src";
33
import { resolveFixture, transpileFilesResult } from "./run";
44

5-
interface DirectoryTestCase {
6-
name: string;
7-
options: tstl.CompilerOptions;
8-
}
5+
const projectRoot = resolveFixture("directories");
6+
test.each([{}, { outDir: "out" }, { rootDir: "src" }, { rootDir: "src", outDir: "out" }])(
7+
"should be able to resolve (%p)",
8+
tsconfigOptions => {
9+
jest.spyOn(process, "cwd").mockReturnValue(projectRoot);
910

10-
test.each<DirectoryTestCase>([
11-
{ name: "basic", options: {} },
12-
{ name: "basic", options: { outDir: "out" } },
13-
{ name: "basic", options: { rootDir: "src" } },
14-
{ name: "basic", options: { rootDir: "src", outDir: "out" } },
15-
{ name: "baseurl", options: { baseUrl: "./src/lib", rootDir: ".", outDir: "./out" } },
16-
])("should be able to resolve (%p)", ({ name, options: compilerOptions }) => {
17-
const projectPath = resolveFixture(`directories/${name}`);
18-
jest.spyOn(process, "cwd").mockReturnValue(projectPath);
11+
const config = {
12+
compilerOptions: { ...tsconfigOptions, types: [], skipLibCheck: true },
13+
tstl: { luaTarget: tstl.LuaTarget.LuaJIT, luaLibImport: tstl.LuaLibImportKind.Always },
14+
};
1915

20-
const config = {
21-
compilerOptions: { ...compilerOptions, types: [], skipLibCheck: true },
22-
tstl: { luaTarget: tstl.LuaTarget.LuaJIT, luaLibImport: tstl.LuaLibImportKind.Always },
23-
};
16+
const { fileNames, options } = tstl.updateParsedConfigFile(
17+
ts.parseJsonConfigFileContent(config, ts.sys, projectRoot)
18+
);
2419

25-
const { fileNames, options } = tstl.updateParsedConfigFile(
26-
ts.parseJsonConfigFileContent(config, ts.sys, projectPath)
27-
);
28-
29-
const { diagnostics, emittedFiles } = transpileFilesResult(fileNames, options);
30-
expect(diagnostics).not.toHaveDiagnostics();
31-
expect(emittedFiles.map(f => f.name).sort()).toMatchSnapshot();
32-
});
20+
const { diagnostics, emittedFiles } = transpileFilesResult(fileNames, options);
21+
expect(diagnostics).not.toHaveDiagnostics();
22+
expect(emittedFiles.map(f => f.name).sort()).toMatchSnapshot();
23+
}
24+
);

0 commit comments

Comments
 (0)