Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rewire.test.js « test - github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5bb6d9aa930163eb6465f0c1fc7f2eebe4675b1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Don't run code in ES5 strict mode.
// In case this module was in strict mode, all other modules called by this would also be strict.
// But when testing if the strict mode is preserved, we must ensure that this module is NOT strict.

var expect = require("expect.js");

var rewire;

describe("rewire", function () {
    before(require("./testHelpers/createFakePackageJSON.js"));
    after(require("./testHelpers/removeFakePackageJSON.js"));
    it("should pass all shared test cases", function () {
        require("./testModules/sharedTestCases.js");
    });
    it("should also work with CoffeeScript", function () {
        var coffeeModule;

        rewire = require("rewire");
        coffeeModule = rewire("./testModules/module.coffee");
        coffeeModule.__set__("fs", {
            readFileSync: function () {
                return "It works!";
            }
        });
        expect(coffeeModule.readFileSync()).to.be("It works!");
    });
});