Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohannes Ewald <johannes.ewald@peerigon.com>2014-11-04 11:36:40 +0300
committerJohannes Ewald <johannes.ewald@peerigon.com>2014-11-04 11:36:40 +0300
commit09dc5be9128bb07766b01bda9e053046478f9a03 (patch)
tree2923821380c843c74cd5cf9f3b71eae17e945f56 /test
parent1eede09155581d71bc311e0b7d16e0109d607e05 (diff)
Fix shadowing of internal `module`, `exports` and `require` when a global counterpart exists
@see https://github.com/jhnns/rewire-webpack/pull/6
Diffstat (limited to 'test')
-rw-r--r--test/getImportGlobalsSrc.test.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/getImportGlobalsSrc.test.js b/test/getImportGlobalsSrc.test.js
index e733614..7e2043b 100644
--- a/test/getImportGlobalsSrc.test.js
+++ b/test/getImportGlobalsSrc.test.js
@@ -7,11 +7,24 @@ describe("getImportGlobalsSrc", function () {
var context = {
global: global
},
+ expectedGlobals,
src,
- actualGlobals,
- expectedGlobals = Object.keys(global);
+ actualGlobals;
+
+ // Temporarily set module-internal variables on the global scope to check if getImportGlobalsSrc()
+ // ignores them properly
+ global.module = module;
+ global.exports = exports;
+ global.require = require;
src = getImportGlobalsSrc();
+
+ delete global.module;
+ delete global.exports;
+ delete global.require;
+
+ expectedGlobals = Object.keys(global);
+
vm.runInNewContext(src, context);
actualGlobals = Object.keys(context).filter(function (key) {
// node v0.10 does not set a constructor property on the context