Skip to content

Commit 464614c

Browse files
committed
Add a test for multi-file projects
1 parent 24e1aa6 commit 464614c

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

test/test-runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function main() {
2828
main();
2929

3030
async function compileAllAsc() {
31-
const ascFiles = await glob("./tests/**/*.ts");
31+
const ascFiles = await glob("./tests/**/asc.ts");
3232
const transformFile = require.resolve("../transform.js");
3333
for (const ascFile of ascFiles) {
3434
console.log(`Compiling ${ascFile}...`);

test/tests/multifile/asc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { swapAndPad } from "./exports";

test/tests/multifile/exports.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { swappedConcat } from "./imports";
2+
3+
export function addExclamations(s: string): string {
4+
return "!" + s + "!";
5+
}
6+
7+
export function swapAndPad(a: string, b: string): string {
8+
return addExclamations(swappedConcat(a, b));
9+
}

test/tests/multifile/imports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function swappedConcat(a: string, b: string): string;

test/tests/multifile/test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
describe("as-bind", function() {
2+
it("should handle multiple files correctly", async function() {
3+
const instance = await AsBind.instantiate(this.rawModule, {
4+
imports: {
5+
swappedConcat(a, b) {
6+
return b + a;
7+
}
8+
}
9+
});
10+
assert(typeof instance.exports.addExclamations === "undefined");
11+
assert(instance.exports.swapAndPad("a", "b") === "!ba!");
12+
});
13+
});

0 commit comments

Comments
 (0)