aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/module/node-module-module.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-03 18:22:31 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-03 18:22:45 -0700
commitc2ebdf812b4d23a89367de2e238c5a534f693e95 (patch)
treefcb1258b2a50dd4d7e17539ab625b9949a94709f /test/js/node/module/node-module-module.test.js
parent9ab2acced6a882dd0c21a4e1e94f427ad9d08966 (diff)
downloadbun-c2ebdf812b4d23a89367de2e238c5a534f693e95.tar.gz
bun-c2ebdf812b4d23a89367de2e238c5a534f693e95.tar.zst
bun-c2ebdf812b4d23a89367de2e238c5a534f693e95.zip
Test for Module.wrap()
Diffstat (limited to 'test/js/node/module/node-module-module.test.js')
-rw-r--r--test/js/node/module/node-module-module.test.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/js/node/module/node-module-module.test.js b/test/js/node/module/node-module-module.test.js
index fd43c7353..c988cd8c7 100644
--- a/test/js/node/module/node-module-module.test.js
+++ b/test/js/node/module/node-module-module.test.js
@@ -1,5 +1,5 @@
import { expect, test } from "bun:test";
-import { _nodeModulePaths, builtinModules, isBuiltin } from "module";
+import { _nodeModulePaths, builtinModules, isBuiltin, wrap } from "module";
import Module from "module";
test("builtinModules exists", () => {
@@ -43,3 +43,9 @@ test("_nodeModulePaths() works", () => {
]);
expect(_nodeModulePaths("/a/b/../d")).toEqual(["/a/d/node_modules", "/a/node_modules", "/node_modules"]);
});
+
+test("Module.wrap", () => {
+ var mod = { exports: {} };
+ expect(eval(wrap("exports.foo = 1; return 42"))(mod, mod.exports)).toBe(42);
+ expect(wrap()).toBe("(function (exports, require, module, __filename, __dirname) { undefined\n});");
+});