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:
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