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

Skip to content

Commit f5fd56e

Browse files
committed
- added a test for the case where a comment is on the last line
1 parent 1a807a5 commit f5fd56e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/testModules/emptyModule.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
"use strict"; // run code in ES5 strict mode
2+
3+
var someVar;
4+
5+
// Comment on file end. Hope this won't break anything

test/testModules/sharedTestCases.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
145145
}
146146
}
147147
});
148+
it("should not be a problem to have a comment on file end", function () {
149+
var rewired = rewire("./emptyModule.js");
150+
151+
rewired.__set__("someVar", "hello");
152+
expect(rewired.__get__("someVar")).to.be("hello");
153+
});
148154
it("should not influence the original require if nothing has been required within the rewired module", function () {
149155
rewire("./emptyModule.js"); // nothing happens here because emptyModule doesn't require anything
150156
expect(require("./moduleA.js").__set__).to.be(undefined); // if restoring the original node require didn't worked, the module would have a setter

0 commit comments

Comments
 (0)