Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli White <github@eli-white.com>2015-10-13 04:34:53 +0300
committerEli White <github@eli-white.com>2015-10-13 04:34:53 +0300
commit983450ea362877aa3259a61a9a394d84ffa193e7 (patch)
tree0338cc4b45206b6bda1b27131cee727c3b3f7044
parent851c1032dcf4b15a251eef06e9f10b57a57bc31c (diff)
Make properties writable
-rw-r--r--lib/getDefinePropertySrc.js5
-rw-r--r--test/testModules/sharedTestCases.js17
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 () {