From b752ffb9fb9aed8cdc89d3b95bf7ea3856e0ed86 Mon Sep 17 00:00:00 2001 From: Eli White Date: Sat, 7 Nov 2015 13:52:31 -0800 Subject: Should not blow up on modules that export primitives --- testLib/boolean.js | 1 + testLib/null.js | 1 + testLib/sealedObject.js | 4 ++++ testLib/sharedTestCases.js | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 testLib/boolean.js create mode 100644 testLib/null.js create mode 100644 testLib/sealedObject.js (limited to 'testLib') 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 -- cgit v1.2.3