Skip to content

Commit

Permalink
Move testLib into dedicated folder inside root folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Nov 15, 2015
1 parent 5a8ba82 commit a7bdea2
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 15 deletions.
8 changes: 5 additions & 3 deletions .istanbul.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
instrumentation:
# These functions will be stringified and evaled again. Thus it's difficult to include them into the test coverage
excludes: [
# These functions will be stringified and evaled again. Thus it's difficult to include them into the test coverage
'lib/__get__.js',
'lib/__set__.js',
'lib/__with__.js'
]
'lib/__with__.js',
# Ignore shared test cases. These are just in the lib folder because they should
'testLib/*'
]
3 changes: 0 additions & 3 deletions lib/testModules/node_modules/rewire/package.json

This file was deleted.

8 changes: 4 additions & 4 deletions test/rewire.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ var rewire;

describe("rewire", function () {
before(function () {
var fakeNodeModules = path.resolve(__dirname, "testModules/fake_node_modules");
var fakeNodeModules = path.resolve(__dirname, "../testLib/fake_node_modules");

if (fs.existsSync(fakeNodeModules)) {
fs.renameSync(fakeNodeModules, path.resolve(__dirname, "testModules/node_modules"));
fs.renameSync(fakeNodeModules, path.resolve(__dirname, "../testLib/node_modules"));
}
});
it("should pass all shared test cases", function () {
require("../lib/testModules/sharedTestCases.js");
require("../testLib/sharedTestCases.js");
});
it("should also work with CoffeeScript", function () {
var coffeeModule;

rewire = require("../");
coffeeModule = rewire("../lib/testModules/module.coffee");
coffeeModule = rewire("../testLib/module.coffee");
coffeeModule.__set__("fs", {
readFileSync: function () {
return "It works!";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions testLib/node_modules/rewire/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

var expect = require("expect.js"),
rewire = require("rewire"),
__set__Src = require("../../lib/__set__.js").toString(),
__get__Src = require("../../lib/__get__.js").toString(),
__with__Src = require("../../lib/__with__.js").toString();
__set__Src = require("../lib/__set__.js").toString(),
__get__Src = require("../lib/__get__.js").toString(),
__with__Src = require("../lib/__with__.js").toString();

function checkForTypeError(err) {
expect(err.constructor).to.be(TypeError);
Expand All @@ -23,7 +23,7 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
rewire("./moduleA.js").getFilename();
require("./moduleA.js").getFilename();
expect(rewire("./moduleA.js").getFilename()).to.eql(require("./moduleA.js").getFilename());
expect(rewire("../testModules/someOtherModule.js").filename).to.eql(require("../testModules/someOtherModule.js").filename);
expect(rewire("../testLib/someOtherModule.js").filename).to.eql(require("../testLib/someOtherModule.js").filename);
});

it("should return a fresh instance of the module", function () {
Expand Down Expand Up @@ -69,7 +69,7 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +

["__get__", "__set__", "__with__"].forEach(function(funcName) {
it("should provide " + funcName + " as a non-enumerable property", function () {
expect(Object.keys(rewire("./moduleA.js")).indexOf(funcName)).to.be(-1)
expect(Object.keys(rewire("./moduleA.js")).indexOf(funcName)).to.be(-1);
});

it("should provide " + funcName + " as a writable property", function () {
Expand Down Expand Up @@ -240,6 +240,9 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
it("should not modify line numbers in stack traces", function () {
var throwError = rewire("./throwError.js");

if (process.env.running_under_istanbul === "1") {
return;
}
try {
throwError();
} catch (err) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a7bdea2

Please sign in to comment.