diff options
Diffstat (limited to 'testLib/sharedTestCases.js')
-rw-r--r-- | testLib/sharedTestCases.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testLib/sharedTestCases.js b/testLib/sharedTestCases.js index 54e4218..310071a 100644 --- a/testLib/sharedTestCases.js +++ b/testLib/sharedTestCases.js @@ -372,4 +372,32 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv + revert(); }); + it("Should be possible to mock a const variable using __with__ syntax", function() { + var ES2015Module = rewire("./ES2015Module", { + convertConst: true + }); + + ES2015Module.__with__({ + language: "en" + })(function() { + expect(ES2015Module.getLang()).to.equal("en"); + expect(ES2015Module.getOtherModuleName()).to.equal("somOtherModule"); + }) + }) + + it("Should be possible to mock a const required variable using __with__ syntax", function() { + var ES2015Module = rewire("./ES2015Module", { + convertConst: true + }); + + ES2015Module.__with__({ + someOtherModule: { + name: "mocked" + } + })(function() { + expect(ES2015Module.getLang()).to.equal("nl"); + expect(ES2015Module.getOtherModuleName()).to.equal("mocked"); + }) + }) + }); |