Skip to content

Commit

Permalink
Adding a test case for null
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSavior committed Nov 30, 2015
1 parent 562f8a6 commit 6f5252f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/getDefinePropertySrc.js
Expand Up @@ -12,7 +12,7 @@ var srcs = {

function getDefinePropertySrc() {
var src = "if (typeof(module.exports) === 'function' || \n" +
"(typeof(module.exports) === 'object' && Object.isExtensible(module.exports))) {\n";
"(typeof(module.exports) === 'object' && module.exports !== null && Object.isExtensible(module.exports))) {\n";

src += Object.keys(srcs).reduce(function forEachSrc(preValue, value) {
return preValue += "Object.defineProperty(module.exports, '" +
Expand Down
1 change: 1 addition & 0 deletions testLib/null.js
@@ -0,0 +1 @@
module.exports = null;
8 changes: 7 additions & 1 deletion testLib/sharedTestCases.js
Expand Up @@ -220,12 +220,18 @@ 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 primitive", function() {
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");
Expand Down

0 comments on commit 6f5252f

Please sign in to comment.