From 9597e469871ba1b0b457da9cb2c675fe8f24767b Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Sun, 14 Dec 2014 02:21:21 +0100 Subject: [PATCH] Add test for implicit global vars #35 --- test/testModules/implicitGlobal.js | 2 ++ test/testModules/sharedTestCases.js | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/testModules/implicitGlobal.js 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);