Skip to content

Commit

Permalink
Move shared test cases into lib folder
Browse files Browse the repository at this point in the history
Since new versions of npm respect the .npmignore even when it comes
from git urls, we need to move the shared test cases into the lib folder
in order to provide these cases to other modules which port rewire's
functionality to other environments.

As discussed at jhnns/rewire-webpack#18
  • Loading branch information
jhnns committed Nov 14, 2015
1 parent ac0c8a3 commit 5a8ba82
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict"; // run code in ES5 strict mode

var myNumber = 0;

module.exports = function () {
myNumber = 1;
"use strict"; // run code in ES5 strict mode

var myNumber = 0;

module.exports = function () {
myNumber = 1;
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict"; // run code in ES5 strict mode

var someVar;

"use strict"; // run code in ES5 strict mode

var someVar;

// Comment on file end. Hope this won't break anything
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict"; // run code in ES5 strict mode

function doSomethingUnstrict() {
var caller = arguments.callee.caller; // this should throw an error as a proof that strict mode is on
}

"use strict"; // run code in ES5 strict mode

function doSomethingUnstrict() {
var caller = arguments.callee.caller; // this should throw an error as a proof that strict mode is on
}

exports.doSomethingUnstrict = doSomethingUnstrict;
File renamed without changes.
6 changes: 3 additions & 3 deletions test/rewire.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ describe("rewire", function () {
}
});
it("should pass all shared test cases", function () {
require("./testModules/sharedTestCases.js");
require("../lib/testModules/sharedTestCases.js");
});
it("should also work with CoffeeScript", function () {
var coffeeModule;

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

0 comments on commit 5a8ba82

Please sign in to comment.