Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9597e46

Browse files
committed
Add test for implicit global vars
jhnns#35
1 parent be744f2 commit 9597e46

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/testModules/implicitGlobal.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
implicitGlobal = "this is an implicit global var ..." +
2+
"yes, it's bad coding style but there are still some libs out there";

test/testModules/sharedTestCases.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
248248
}
249249
});
250250

251+
it("should be possible to set implicit globals", function () {
252+
var implicitGlobalModule = rewire("./implicitGlobal.js");
253+
254+
implicitGlobalModule.__set__("implicitGlobal", true);
255+
expect(implicitGlobalModule.__get__("implicitGlobal")).to.be(true);
256+
// setting implicit global vars will change them globally instead of locally.
257+
// that's a shortcoming of the current implementation which can't be solved easily.
258+
//expect(implicitGlobal).to.be.a("string");
259+
});
260+
251261
it("should throw a TypeError if the path is not a string", function () {
252262
expect(function () {
253263
rewire(null);

0 commit comments

Comments
 (0)