Skip to content

Commit

Permalink
Add a test for multi-file projects
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Mar 15, 2021
1 parent 24e1aa6 commit 464614c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function main() {
main();

async function compileAllAsc() {
const ascFiles = await glob("./tests/**/*.ts");
const ascFiles = await glob("./tests/**/asc.ts");
const transformFile = require.resolve("../transform.js");
for (const ascFile of ascFiles) {
console.log(`Compiling ${ascFile}...`);
Expand Down
1 change: 1 addition & 0 deletions test/tests/multifile/asc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { swapAndPad } from "./exports";
9 changes: 9 additions & 0 deletions test/tests/multifile/exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { swappedConcat } from "./imports";

export function addExclamations(s: string): string {
return "!" + s + "!";
}

export function swapAndPad(a: string, b: string): string {
return addExclamations(swappedConcat(a, b));
}
1 change: 1 addition & 0 deletions test/tests/multifile/imports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function swappedConcat(a: string, b: string): string;
13 changes: 13 additions & 0 deletions test/tests/multifile/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe("as-bind", function() {
it("should handle multiple files correctly", async function() {
const instance = await AsBind.instantiate(this.rawModule, {
imports: {
swappedConcat(a, b) {
return b + a;
}
}
});
assert(typeof instance.exports.addExclamations === "undefined");
assert(instance.exports.swapAndPad("a", "b") === "!ba!");
});
});

0 comments on commit 464614c

Please sign in to comment.