diff --git a/lib/getDefinePropertySrc.js b/lib/getDefinePropertySrc.js index 95dd9f2..b856a7f 100644 --- a/lib/getDefinePropertySrc.js +++ b/lib/getDefinePropertySrc.js @@ -18,10 +18,11 @@ function getDefinePropertySrc() { value + "', {enumerable: false, value: " + srcs[value] + - "}); "; + ", "+ + "writable: true}); "; }, ""); return src; } -module.exports = getDefinePropertySrc; \ No newline at end of file +module.exports = getDefinePropertySrc; diff --git a/test/testModules/sharedTestCases.js b/test/testModules/sharedTestCases.js index 7048ba8..ccbafa3 100644 --- a/test/testModules/sharedTestCases.js +++ b/test/testModules/sharedTestCases.js @@ -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 () {