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>2014-12-14 04:21:21 +0300
committerJohannes Ewald <johannes.ewald@peerigon.com>2014-12-14 04:21:21 +0300
commit9597e469871ba1b0b457da9cb2c675fe8f24767b (patch)
tree5696d9bbf829e2894874afc704bd7b68a1b83fc9 /test
parentbe744f257c1f8c822598456de131d1cacce6690b (diff)
Add test for implicit global vars
#35
Diffstat (limited to 'test')
-rw-r--r--test/testModules/implicitGlobal.js2
-rw-r--r--test/testModules/sharedTestCases.js10
2 files changed, 12 insertions, 0 deletions
diff --git a/test/testModules/implicitGlobal.js b/test/testModules/implicitGlobal.js
new file mode 100644
index 0000000..9bc3e2a
--- /dev/null
+++ b/test/testModules/implicitGlobal.js
@@ -0,0 +1,2 @@
+implicitGlobal = "this is an implicit global var ..." +
+ "yes, it's bad coding style but there are still some libs out there"; \ No newline at end of file
diff --git a/test/testModules/sharedTestCases.js b/test/testModules/sharedTestCases.js
index 9e667e3..785b41b 100644
--- a/test/testModules/sharedTestCases.js
+++ b/test/testModules/sharedTestCases.js
@@ -248,6 +248,16 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
}
});
+ it("should be possible to set implicit globals", function () {
+ var implicitGlobalModule = rewire("./implicitGlobal.js");
+
+ implicitGlobalModule.__set__("implicitGlobal", true);
+ expect(implicitGlobalModule.__get__("implicitGlobal")).to.be(true);
+ // setting implicit global vars will change them globally instead of locally.
+ // that's a shortcoming of the current implementation which can't be solved easily.
+ //expect(implicitGlobal).to.be.a("string");
+ });
+
it("should throw a TypeError if the path is not a string", function () {
expect(function () {
rewire(null);