diff options
author | Johannes Ewald <mail@johannesewald.de> | 2015-11-07 19:09:10 +0300 |
---|---|---|
committer | Johannes Ewald <mail@johannesewald.de> | 2015-11-07 19:09:10 +0300 |
commit | 23b79a82f6625a24fd3b26ed70dae9570e08131d (patch) | |
tree | 0338cc4b45206b6bda1b27131cee727c3b3f7044 | |
parent | 851c1032dcf4b15a251eef06e9f10b57a57bc31c (diff) | |
parent | 983450ea362877aa3259a61a9a394d84ffa193e7 (diff) |
Merge pull request #78 from TheSavior/writable
Enable rewiring rewired modules
-rw-r--r-- | lib/getDefinePropertySrc.js | 5 | ||||
-rw-r--r-- | test/testModules/sharedTestCases.js | 17 |
2 files changed, 12 insertions, 10 deletions
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 () { |