Skip to content

Commit 994e989

Browse files
committed
add test
1 parent eef171f commit 994e989

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

tests/helpers.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,28 @@ export * from "@deno/loader";
1212
export async function createLoader(
1313
workspaceOptions: WorkspaceOptions,
1414
loaderOptions: LoaderOptions,
15+
) {
16+
const { loader, workspace, diagnostics } = await createLoaderWithDiagnostics(
17+
workspaceOptions,
18+
loaderOptions,
19+
);
20+
assertEquals(diagnostics, []);
21+
return {
22+
loader,
23+
workspace,
24+
};
25+
}
26+
27+
export async function createLoaderWithDiagnostics(
28+
workspaceOptions: WorkspaceOptions,
29+
loaderOptions: LoaderOptions,
1530
) {
1631
const workspace = new Workspace(workspaceOptions);
1732
const { loader, diagnostics } = await workspace.createLoader(loaderOptions);
18-
assertEquals(diagnostics, []);
1933
return {
2034
loader,
2135
workspace,
36+
diagnostics,
2237
};
2338
}
2439

tests/invalid_graph/main.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { assertEquals } from "@std/assert";
2+
import { createLoaderWithDiagnostics } from "../helpers.ts";
3+
4+
Deno.test("loads linked entrypoint", async () => {
5+
const mainFile = import.meta.dirname + "/testdata/main.ts";
6+
const { diagnostics } = await createLoaderWithDiagnostics({
7+
configPath: import.meta.dirname + "/testdata/deno.json",
8+
}, {
9+
entrypoints: [mainFile],
10+
});
11+
12+
assertEquals(diagnostics.length, 1);
13+
const expectedMessage =
14+
'Relative import path "unknown" not prefixed with / or ./ or ../';
15+
assertEquals(
16+
diagnostics[0].message.substring(0, expectedMessage.length),
17+
expectedMessage,
18+
);
19+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "unknown";

0 commit comments

Comments
 (0)