diff options
author | Eli White <github@eli-white.com> | 2015-11-08 00:52:31 +0300 |
---|---|---|
committer | Eli White <github@eli-white.com> | 2015-11-30 20:29:32 +0300 |
commit | b752ffb9fb9aed8cdc89d3b95bf7ea3856e0ed86 (patch) | |
tree | c14a60e1b7eee23235b451fa391331cd9815b597 /testLib | |
parent | a4fc3a852d1749cb6491c7a337d4ad4720248df6 (diff) |
Should not blow up on modules that export primitives
Diffstat (limited to 'testLib')
-rw-r--r-- | testLib/boolean.js | 1 | ||||
-rw-r--r-- | testLib/null.js | 1 | ||||
-rw-r--r-- | testLib/sealedObject.js | 4 | ||||
-rw-r--r-- | testLib/sharedTestCases.js | 18 |
4 files changed, 24 insertions, 0 deletions
diff --git a/testLib/boolean.js b/testLib/boolean.js new file mode 100644 index 0000000..ec01c2c --- /dev/null +++ b/testLib/boolean.js @@ -0,0 +1 @@ +module.exports = true; diff --git a/testLib/null.js b/testLib/null.js new file mode 100644 index 0000000..b894a23 --- /dev/null +++ b/testLib/null.js @@ -0,0 +1 @@ +module.exports = null; diff --git a/testLib/sealedObject.js b/testLib/sealedObject.js new file mode 100644 index 0000000..72881a8 --- /dev/null +++ b/testLib/sealedObject.js @@ -0,0 +1,4 @@ +var obj = {}; +Object.seal(obj); + +module.exports = obj; diff --git a/testLib/sharedTestCases.js b/testLib/sharedTestCases.js index 9fb83ed..54e4218 100644 --- a/testLib/sharedTestCases.js +++ b/testLib/sharedTestCases.js @@ -220,6 +220,24 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv + expect(rewired.__get__("someVar")).to.be("hello"); }); + it("should not be a problem to have a module that exports a boolean", function() { + expect(function() { + var rewired = rewire("./boolean.js"); + }).to.not.throwException(); + }); + + it("should not be a problem to have a module that exports null", function() { + expect(function() { + var rewired = rewire("./null.js"); + }).to.not.throwException(); + }); + + it("should not be a problem to have a module that exports a sealed object", function() { + expect(function() { + var rewired = rewire("./sealedObject.js"); + }).to.not.throwException(); + }); + it("should not influence the original require if nothing has been required within the rewired module", function () { rewire("./emptyModule.js"); // nothing happens here because emptyModule doesn't require anything expect(require("./moduleA.js").__set__).to.be(undefined); // if restoring the original node require didn't worked, the module would have a setter |