Skip to content

Commit

Permalink
test: added import dir tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbjgolden committed Sep 29, 2024
1 parent d346b9f commit 687d711
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dist
!.scripts
.scripts/benchmark/node_modules
.scripts/benchmark/package-lock.json
.DS_Store
4 changes: 4 additions & 0 deletions lib/__fixtures__/import-dir/dir/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
console.log("dir");
export const dir = () => {
console.log("dir2");
};
4 changes: 4 additions & 0 deletions lib/__fixtures__/import-dir/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {dir} from "./dir";

console.log("index");
dir();
36 changes: 36 additions & 0 deletions lib/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,42 @@ test("run a file directly (ansi escape)", async () => {
expect(stderr).toBe("");
});

test("can import dir from dependency", async () => {
let stdout = "";
let stderr = "";
await expect(
run({
filePath: "lib/__fixtures__/import-dir/index.ts",
onWriteStdout: (out) => {
stdout += out;
},
onWriteStderr: (err) => {
stderr += err;
},
})
).resolves.toBe(0);
expect(stdout).toBe("dir\nindex\ndir2\n");
expect(stderr).toBe("");
});

test("can import dir directly", async () => {
let stdout = "";
let stderr = "";
await expect(
run({
filePath: "lib/__fixtures__/import-dir/dir",
onWriteStdout: (out) => {
stdout += out;
},
onWriteStderr: (err) => {
stderr += err;
},
})
).resolves.toBe(0);
expect(stdout).toBe("dir\n");
expect(stderr).toBe("");
});

test("run a file directly (dep has js syntax error)", async () => {
let stdout = "";
let stderr = "";
Expand Down

0 comments on commit 687d711

Please sign in to comment.