Skip to content

Commit

Permalink
Add test for implicit global vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Dec 14, 2014
1 parent be744f2 commit 9597e46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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";
10 changes: 10 additions & 0 deletions test/testModules/sharedTestCases.js
Expand Up @@ -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);
Expand Down

0 comments on commit 9597e46

Please sign in to comment.