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

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rewire.test.js (renamed from test/internalRewire.test.js)18
-rw-r--r--test/testModules/module.coffee3
2 files changed, 20 insertions, 1 deletions
diff --git a/test/internalRewire.test.js b/test/rewire.test.js
index 3b3a303..5bb6d9a 100644
--- a/test/internalRewire.test.js
+++ b/test/rewire.test.js
@@ -2,10 +2,26 @@
// 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.
-describe("internalRewire", function () {
+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!");
+ });
}); \ No newline at end of file
diff --git a/test/testModules/module.coffee b/test/testModules/module.coffee
new file mode 100644
index 0000000..02fa5d5
--- /dev/null
+++ b/test/testModules/module.coffee
@@ -0,0 +1,3 @@
+fs = require "fs"
+
+exports.readFileSync = () -> fs.readFileSync() \ No newline at end of file