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 <johannes.ewald@roomieplanet.de>2012-06-21 02:24:09 +0400
committerJohannes <johannes.ewald@roomieplanet.de>2012-06-21 02:24:09 +0400
commit0c860734dc28a679d9214ee9c5b5ff95e00eed55 (patch)
tree2b76efd42c12f331b79e61fb88ac480119d971c3 /test/rewire.test.js
parentce972e2b1a9a43f6c19a68a5701b1b3b1bcc67f8 (diff)
removed "use strict"; to avoid influencing not-strict modules
Diffstat (limited to 'test/rewire.test.js')
-rw-r--r--test/rewire.test.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/rewire.test.js b/test/rewire.test.js
index 1e40041..fa17088 100644
--- a/test/rewire.test.js
+++ b/test/rewire.test.js
@@ -1,4 +1,6 @@
-"use strict"; // run code in ES5 strict mode
+// Don't run code in ES5 strict mode.
+// In case this module was in strict mode, all other modules called by this would also be strict.
+// But when testing if the strict mode is preserved, we must ensure that this module is NOT strict.
var path = require("path"),
expect = require("expect.js"),
@@ -8,9 +10,15 @@ var testModules = {
A: path.resolve(__dirname, "./testModules/moduleA.js"),
B: path.resolve(__dirname, "./testModules/moduleB.js"),
someOtherModule: path.resolve(__dirname, "./testModules/someOtherModule.js"),
- emptyModule: path.resolve(__dirname, "./testModules/emptyModule.js")
+ emptyModule: path.resolve(__dirname, "./testModules/emptyModule.js"),
+ strictModule: path.resolve(__dirname, "./testModules/strictModule.js")
};
+
+function checkForTypeError(err) {
+ expect(err.constructor).to.be(TypeError);
+}
+
function cleanRequireCache() {
var moduleName,
modulePath;
@@ -140,6 +148,13 @@ describe("rewire", function () {
it("subsequent calls of rewire should always return a new instance", function () {
expect(rewire(testModules.A)).not.to.be(rewire(testModules.A));
});
+ it("should preserve the strict mode", function () {
+ var strictModule = rewire(testModules.strictModule);
+
+ expect(function () {
+ strictModule.doSomethingUnstrict();
+ }).to.throwException(checkForTypeError);
+ });
describe("#reset", function () {
it("should remove all rewired modules from cache", function () {
var rewiredModuleA = rewire(testModules.A),