/
entry-point.test.ts
86 lines (74 loc) · 2.38 KB
/
entry-point.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
import { tempdirProject } from "@typestrong/fs-fixture-builder";
import { deepStrictEqual as equal, ok } from "assert";
import { join } from "path";
import { Application, EntryPointStrategy, TSConfigReader } from "../..";
const fixture = tempdirProject();
fixture.addJsonFile("tsconfig.json", {
include: ["."],
});
fixture.addFile("index.ts", "export function fromIndex() {}");
fixture.addFile("extra.ts", "export function extra() {}");
describe("Entry Points", () => {
beforeEach(() => {
fixture.write();
});
afterEach(() => {
fixture.rm();
});
const app = new Application();
const tsconfig = join(fixture.cwd, "tsconfig.json");
app.options.addReader(new TSConfigReader());
it("Supports expanding existing paths", () => {
app.bootstrap({
tsconfig,
entryPoints: [fixture.cwd],
entryPointStrategy: EntryPointStrategy.Expand,
});
const entryPoints = app.getEntryPoints();
ok(entryPoints);
equal(
entryPoints.length,
2,
"There are two files, so both should be expanded"
);
});
it("Supports expanding globs in paths", () => {
app.bootstrap({
tsconfig,
entryPoints: [`${fixture.cwd}/*.ts`],
entryPointStrategy: EntryPointStrategy.Expand,
});
const entryPoints = app.getEntryPoints();
ok(entryPoints);
equal(
entryPoints.length,
2,
"There are two files, so both should be expanded"
);
});
it("Supports resolving directories", () => {
app.bootstrap({
tsconfig,
entryPoints: [fixture.cwd],
entryPointStrategy: EntryPointStrategy.Resolve,
});
const entryPoints = app.getEntryPoints();
ok(entryPoints);
equal(
entryPoints.length,
1,
"entry-points/index.ts should have been the sole entry point"
);
});
it("Supports resolving packages", () => {
const root = join(__dirname, "../packages/multi-package");
app.bootstrap({
tsconfig: root,
entryPoints: [root],
entryPointStrategy: EntryPointStrategy.Packages,
});
const entryPoints = app.getEntryPoints();
ok(entryPoints);
equal(entryPoints.length, 3);
});
});