From 5a8ba82b39f69f3750ddf83c6f6fc6f6e2ecb2a2 Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Sat, 14 Nov 2015 18:59:06 +0100 Subject: [PATCH] Move shared test cases into lib folder 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 https://github.com/jhnns/rewire-webpack/pull/18 --- {test => lib}/testModules/debuggerModule.js | 12 ++++++------ {test => lib}/testModules/emptyModule.js | 8 ++++---- {test => lib}/testModules/implicitGlobal.js | 0 {test => lib}/testModules/module.coffee | 0 {test => lib}/testModules/moduleA.js | 0 {test => lib}/testModules/moduleB.js | 0 .../testModules/node_modules/rewire/package.json | 0 {test => lib}/testModules/sharedTestCases.js | 0 {test => lib}/testModules/someOtherModule.js | 0 {test => lib}/testModules/strictModule.js | 12 ++++++------ {test => lib}/testModules/throwError.js | 0 test/rewire.test.js | 6 +++--- 12 files changed, 19 insertions(+), 19 deletions(-) rename {test => lib}/testModules/debuggerModule.js (93%) rename {test => lib}/testModules/emptyModule.js (50%) rename {test => lib}/testModules/implicitGlobal.js (100%) rename {test => lib}/testModules/module.coffee (100%) rename {test => lib}/testModules/moduleA.js (100%) rename {test => lib}/testModules/moduleB.js (100%) rename {test => lib}/testModules/node_modules/rewire/package.json (100%) rename {test => lib}/testModules/sharedTestCases.js (100%) rename {test => lib}/testModules/someOtherModule.js (100%) rename {test => lib}/testModules/strictModule.js (77%) rename {test => lib}/testModules/throwError.js (100%) diff --git a/test/testModules/debuggerModule.js b/lib/testModules/debuggerModule.js similarity index 93% rename from test/testModules/debuggerModule.js rename to lib/testModules/debuggerModule.js index 5a79b53..9d2b7df 100644 --- a/test/testModules/debuggerModule.js +++ b/lib/testModules/debuggerModule.js @@ -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; }; \ No newline at end of file diff --git a/test/testModules/emptyModule.js b/lib/testModules/emptyModule.js similarity index 50% rename from test/testModules/emptyModule.js rename to lib/testModules/emptyModule.js index b9a0f90..8b82a74 100644 --- a/test/testModules/emptyModule.js +++ b/lib/testModules/emptyModule.js @@ -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 \ No newline at end of file diff --git a/test/testModules/implicitGlobal.js b/lib/testModules/implicitGlobal.js similarity index 100% rename from test/testModules/implicitGlobal.js rename to lib/testModules/implicitGlobal.js diff --git a/test/testModules/module.coffee b/lib/testModules/module.coffee similarity index 100% rename from test/testModules/module.coffee rename to lib/testModules/module.coffee diff --git a/test/testModules/moduleA.js b/lib/testModules/moduleA.js similarity index 100% rename from test/testModules/moduleA.js rename to lib/testModules/moduleA.js diff --git a/test/testModules/moduleB.js b/lib/testModules/moduleB.js similarity index 100% rename from test/testModules/moduleB.js rename to lib/testModules/moduleB.js diff --git a/test/testModules/node_modules/rewire/package.json b/lib/testModules/node_modules/rewire/package.json similarity index 100% rename from test/testModules/node_modules/rewire/package.json rename to lib/testModules/node_modules/rewire/package.json diff --git a/test/testModules/sharedTestCases.js b/lib/testModules/sharedTestCases.js similarity index 100% rename from test/testModules/sharedTestCases.js rename to lib/testModules/sharedTestCases.js diff --git a/test/testModules/someOtherModule.js b/lib/testModules/someOtherModule.js similarity index 100% rename from test/testModules/someOtherModule.js rename to lib/testModules/someOtherModule.js diff --git a/test/testModules/strictModule.js b/lib/testModules/strictModule.js similarity index 77% rename from test/testModules/strictModule.js rename to lib/testModules/strictModule.js index 140dd2a..5d6e387 100644 --- a/test/testModules/strictModule.js +++ b/lib/testModules/strictModule.js @@ -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; \ No newline at end of file diff --git a/test/testModules/throwError.js b/lib/testModules/throwError.js similarity index 100% rename from test/testModules/throwError.js rename to lib/testModules/throwError.js diff --git a/test/rewire.test.js b/test/rewire.test.js index 1ac0129..900e0fc 100644 --- a/test/rewire.test.js +++ b/test/rewire.test.js @@ -17,13 +17,13 @@ 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!"; @@ -31,4 +31,4 @@ describe("rewire", function () { }); expect(coffeeModule.readFileSync()).to.be("It works!"); }); -}); \ No newline at end of file +});