diff options
author | Johannes <mail@johannesewald.de> | 2012-06-15 17:48:01 +0400 |
---|---|---|
committer | Johannes <mail@johannesewald.de> | 2012-06-15 17:48:01 +0400 |
commit | 512548d888a8a34c3acf8b4c485579596812e506 (patch) | |
tree | 98cfacbdd7d85cb542f3912ea88ec26f6d89f6e2 /test | |
parent | d936fe1491409573a28cc3a981fc110f08bf6a4c (diff) |
namespaced all variables within the __set__ method so you can really set all variables
Diffstat (limited to 'test')
-rw-r--r-- | test/__set__.test.js | 12 | ||||
-rw-r--r-- | test/rewire.test.js | 1 | ||||
-rw-r--r-- | test/testModules/moduleA.js | 1 |
3 files changed, 13 insertions, 1 deletions
diff --git a/test/__set__.test.js b/test/__set__.test.js index e7950cb..e1565c7 100644 --- a/test/__set__.test.js +++ b/test/__set__.test.js @@ -19,7 +19,14 @@ describe("__set__", function () { beforeEach(function () {
moduleFake = {
myNumber: 0, // copy by value
- myObj: {} // copy by reference
+ myObj: {}, // copy by reference
+
+ // these variables are used within the set method
+ // because there is a eval() statement within the set method
+ // these variables should not override same-named vars of the module
+ key: "key",
+ env: "env",
+ src: "src"
};
vm.runInNewContext(
@@ -67,6 +74,9 @@ describe("__set__", function () { });
}).to.throwException(expectReferenceError);
});
+ it("should not clash with vars used within the set method", function () {
+
+ });
it("should throw a TypeError when passing misfitting params", function () {
expect(function () {
moduleFake.__set__();
diff --git a/test/rewire.test.js b/test/rewire.test.js index 9216af6..1e40041 100644 --- a/test/rewire.test.js +++ b/test/rewire.test.js @@ -63,6 +63,7 @@ describe("rewire", function () { expect(rewiredModuleA.getMyNumber()).to.be(2);
rewiredModuleA.__set__("myObj", newObj);
expect(rewiredModuleA.getMyObj()).to.be(newObj);
+ rewiredModuleA.__set__("env", "ENVENV");
});
it("should provide the ability to get private vars", function () {
var rewiredModuleA = rewire(testModules.A);
diff --git a/test/testModules/moduleA.js b/test/testModules/moduleA.js index 6cc63b2..87f4949 100644 --- a/test/testModules/moduleA.js +++ b/test/testModules/moduleA.js @@ -3,6 +3,7 @@ var someOtherModule = require("./someOtherModule.js"),
myNumber = 0, // copy by value
myObj = {}, // copy by reference
+ env = "bla",
fs = require("fs");
// We need getters and setters for private vars to check if our injected setters and getters actual work
|