|
1 | 1 | import * as path from "path"; |
2 | | -import * as tstl from "../../../src"; |
3 | 2 | import * as util from "../../util"; |
4 | 3 |
|
5 | | -test("should ignore language service plugins", () => { |
| 4 | +test("ignore language service plugins", () => { |
6 | 5 | util.testFunction` |
7 | | - return; |
| 6 | + return false; |
8 | 7 | ` |
9 | | - .setOptions({ plugins: [{ name: path.join(__dirname, "resolve.ts") }] }) |
10 | | - .expectToEqual(undefined); |
| 8 | + .setOptions({ plugins: [{ name: path.join(__dirname, "types.ts") }] }) |
| 9 | + .expectToEqual(false); |
11 | 10 | }); |
12 | 11 |
|
13 | | -describe("resolution", () => { |
14 | | - const testTransform = (transformer: tstl.TransformerImport) => { |
15 | | - util.testFunction` |
16 | | - return; |
17 | | - ` |
18 | | - .setOptions({ plugins: [transformer] }) |
19 | | - .expectToEqual(true); |
20 | | - }; |
21 | | - |
22 | | - test("resolve relative transformer paths", () => { |
23 | | - jest.spyOn(process, "cwd").mockReturnValue(__dirname); |
24 | | - testTransform({ transform: "./resolve.ts" }); |
25 | | - }); |
26 | | - |
27 | | - test("load .js transformers", () => { |
28 | | - testTransform({ transform: path.join(__dirname, "resolve.js") }); |
29 | | - }); |
30 | | - |
31 | | - test("load .ts transformers", () => { |
32 | | - testTransform({ transform: path.join(__dirname, "resolve.ts") }); |
33 | | - }); |
34 | | - |
35 | | - test('"import" option', () => { |
36 | | - testTransform({ transform: path.join(__dirname, "import.ts"), import: "transformer" }); |
37 | | - }); |
| 12 | +test("default type", () => { |
| 13 | + util.testFunction` |
| 14 | + return false; |
| 15 | + ` |
| 16 | + .setOptions({ plugins: [{ transform: path.join(__dirname, "fixtures.ts"), import: "program", value: true }] }) |
| 17 | + .expectToEqual(true); |
| 18 | +}); |
38 | 19 |
|
39 | | - test("error if transformer could not be resolved", () => { |
40 | | - util.testModule`` |
41 | | - .setOptions({ plugins: [{ transform: path.join(__dirname, "error.ts") }] }) |
42 | | - .expectToHaveDiagnostics(); |
43 | | - }); |
| 20 | +test("transformer resolution error", () => { |
| 21 | + util.testModule`` |
| 22 | + .setOptions({ plugins: [{ transform: path.join(__dirname, "error.ts") }] }) |
| 23 | + .expectToHaveDiagnostics(); |
44 | 24 | }); |
45 | 25 |
|
46 | 26 | describe("factory types", () => { |
47 | | - for (const type of ["program", "config", "checker", "raw", "compilerOptions"] as const) { |
48 | | - test(type, () => { |
49 | | - util.testFunction` |
50 | | - return false; |
51 | | - ` |
52 | | - .setOptions({ |
53 | | - plugins: [{ transform: path.join(__dirname, "types.ts"), type, import: type, value: true }], |
54 | | - }) |
55 | | - .expectToEqual(true); |
56 | | - }); |
57 | | - } |
| 27 | + test.each(["program", "config", "checker", "raw", "compilerOptions"] as const)("%s", type => { |
| 28 | + util.testFunction` |
| 29 | + return false; |
| 30 | + ` |
| 31 | + .setOptions({ |
| 32 | + plugins: [{ transform: path.join(__dirname, "fixtures.ts"), type, import: type, value: true }], |
| 33 | + }) |
| 34 | + .expectToEqual(true); |
| 35 | + }); |
58 | 36 | }); |
0 commit comments