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:
authorJohannes <mail@johannesewald.de>2012-06-04 16:35:06 +0400
committerJohannes <mail@johannesewald.de>2012-06-04 16:44:19 +0400
commit52313ef8d2638e5a453dacc7fe5c8d5294013098 (patch)
tree6bd8fb849ec33d824ba3d41cdc1fe3eb60f70fe4 /test/rewire.test.js
parentc6aacb4b4a07bf75dcfab47a226f42d5b7b3ccbf (diff)
introduced require.reset()
Diffstat (limited to 'test/rewire.test.js')
-rw-r--r--test/rewire.test.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/rewire.test.js b/test/rewire.test.js
index 2df19e0..3414399 100644
--- a/test/rewire.test.js
+++ b/test/rewire.test.js
@@ -11,7 +11,6 @@ var testModules = [
path.resolve(__dirname, "./testModules/C/moduleC.js")
];
-
function cleanRequireCache() {
var i;
@@ -20,7 +19,7 @@ function cleanRequireCache() {
}
}
-describe("#rewire", function () {
+describe("rewire", function () {
beforeEach(cleanRequireCache); // ensuring a clean test environment
it("should work like require() when omitting all other params", function () {
expect(rewire("./testModules/A/moduleA.js")).to.be(require("./testModules/A/moduleA.js"));
@@ -120,4 +119,13 @@ describe("#rewire", function () {
moduleB = require("./testModules/A/moduleA.js"); // if restoring the original node require didn't worked, the mock would be applied now
expect(moduleB.c).not.to.be(moduleCMock);
});
+ describe("#reset", function () {
+ it("should remove all rewired modules from cache", function () {
+ var rewired = rewire("./testModules/B/moduleB.js");
+
+ expect(require("./testModules/B/moduleB.js")).to.be(rewired);
+ rewire.reset();
+ expect(require("./testModules/B/moduleB.js")).not.to.be(rewired);
+ });
+ });
}); \ No newline at end of file