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
path: root/test
diff options
context:
space:
mode:
authorJohannes Ewald <johannes.ewald@peerigon.com>2015-02-23 03:31:08 +0300
committerJohannes Ewald <johannes.ewald@peerigon.com>2015-02-23 03:31:08 +0300
commite70efd18f9e1d5993fc0a7f1decb5fe6720b3bd8 (patch)
tree78fd4ec2d58346f17aaf19b313d5864896143052 /test
parent52e914dc8b447d1cf99dd946869e8eafb5b53ae4 (diff)
Fix problems when global objects like JSON, etc. have been rewired
Fixes #40
Diffstat (limited to 'test')
-rw-r--r--test/__set__.test.js8
-rw-r--r--test/testModules/sharedTestCases.js13
2 files changed, 14 insertions, 7 deletions
diff --git a/test/__set__.test.js b/test/__set__.test.js
index ef69a07..efd1eeb 100644
--- a/test/__set__.test.js
+++ b/test/__set__.test.js
@@ -121,11 +121,5 @@ describe("__set__", function () {
expect(function () {
moduleFake.__set__(function () {});
}).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__set__({}, true); // misfitting number of params
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__set__("someVar"); // misfitting number of params
- }).to.throwException(expectTypeError);
});
-}); \ No newline at end of file
+});
diff --git a/test/testModules/sharedTestCases.js b/test/testModules/sharedTestCases.js
index 76498bd..7048ba8 100644
--- a/test/testModules/sharedTestCases.js
+++ b/test/testModules/sharedTestCases.js
@@ -337,4 +337,17 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
}
});
+ it("should be possible to mock and revert JSON.parse (see #40)", function () {
+ var moduleA = rewire("./moduleA.js"),
+ revert;
+
+ revert = moduleA.__set__({
+ JSON: {
+ parse: function () { return true; }
+ }
+ });
+
+ revert();
+ });
+
});