summaryrefslogtreecommitdiff
path: root/js/compiler_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/compiler_test.ts')
-rw-r--r--js/compiler_test.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/js/compiler_test.ts b/js/compiler_test.ts
index d8861e2a9..cc3cda406 100644
--- a/js/compiler_test.ts
+++ b/js/compiler_test.ts
@@ -108,6 +108,12 @@ const moduleMap: {
"/root/project/foo/bar.ts",
fooBarTsSource,
fooBarTsOutput
+ ),
+ "./qat.ts": mockModuleInfo(
+ "foo/qat",
+ "/root/project/foo/qat.ts",
+ "export const foo = 'bar'",
+ null
)
}
};
@@ -275,6 +281,33 @@ test(function compilerMakeDefine() {
// external modules, this is implicitly tested though in
// `compilerRunMultiModule`
+test(function compilerLocalRequire() {
+ const moduleMetaData = new ModuleMetaData(
+ "/root/project/foo/baz.ts",
+ fooBazTsSource,
+ fooBazTsOutput
+ );
+ const localDefine = compilerInstance.makeDefine(moduleMetaData);
+ let requireCallbackCalled = false;
+ localDefine(
+ ["require", "exports"],
+ (_require, _exports, _compiler): void => {
+ assertEqual(typeof _require, "function");
+ _require(
+ ["./qat.ts"],
+ _qat => {
+ requireCallbackCalled = true;
+ assert(_qat);
+ },
+ () => {
+ throw new Error("Should not error");
+ }
+ );
+ }
+ );
+ assert(requireCallbackCalled, "Factory expected to be called");
+});
+
test(function compilerRun() {
// equal to `deno foo/bar.ts`
reset();