Skip to content

Commit

Permalink
Merge pull request #78 from TheSavior/writable
Browse files Browse the repository at this point in the history
Enable rewiring rewired modules
  • Loading branch information
jhnns committed Nov 7, 2015
2 parents 851c103 + 983450e commit 23b79a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/getDefinePropertySrc.js
Expand Up @@ -18,10 +18,11 @@ function getDefinePropertySrc() {
value +
"', {enumerable: false, value: " +
srcs[value] +
"}); ";
", "+
"writable: true}); ";
}, "");

return src;
}

module.exports = getDefinePropertySrc;
module.exports = getDefinePropertySrc;
17 changes: 9 additions & 8 deletions test/testModules/sharedTestCases.js
Expand Up @@ -66,16 +66,17 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
expect(rewire("./moduleB.js").__with__.toString()).to.be(__with__Src);
});

it("should provide __set__ as a non-enumerable property", function () {
expect(Object.keys(rewire("./moduleA.js")).indexOf("__set__")).to.be(-1)
});

it("should provide __get__ as a non-enumerable property", function () {
expect(Object.keys(rewire("./moduleA.js")).indexOf("__get__")).to.be(-1)
});
["__get__", "__set__", "__with__"].forEach(function(funcName) {
it("should provide " + funcName + " as a non-enumerable property", function () {
expect(Object.keys(rewire("./moduleA.js")).indexOf(funcName)).to.be(-1)
});

it("should provide __with__ as a non-enumerable property", function () {
expect(Object.keys(rewire("./moduleA.js")).indexOf("__with__")).to.be(-1)
it("should provide " + funcName + " as a writable property", function () {
var obj = rewire("./moduleA.js");
var desc = Object.getOwnPropertyDescriptor(obj, funcName);
expect(desc.writable).to.be(true);
});
});

it("should not influence other modules", function () {
Expand Down

0 comments on commit 23b79a8

Please sign in to comment.