Fix wrong regexp replacements

This commit is contained in:
Florent Cailhol 2018-01-30 21:03:23 +01:00
parent b7ce843240
commit aa217e9abc
28 changed files with 25 additions and 140 deletions

View File

@ -56,7 +56,6 @@
"react-dom": "^15.2.1",
"rimraf": "^2.6.2",
"script-loader": "~0.7.0",
"should": "^11.1.1",
"simple-git": "^1.65.0",
"sinon": "^2.3.2",
"style-loader": "^0.19.1",

View File

@ -1,11 +1,9 @@
"use strict";
require("should");
const path = require("path");
const webpack = require("../lib/webpack");
describe("Integration", function() {
describe("Integration", () => {
jest.setTimeout(5000);
it("should compile library1", (done) => {
webpack({
@ -52,13 +50,6 @@ describe("Integration", function() {
optimization: {
minimize: false
},
resolve: {
// cannot resolve should outside the outermost node_modules
// so it is injected here
alias: {
should: require.resolve("should")
}
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1

View File

@ -1,7 +1,5 @@
"use strict";
const should = require("should");
const RuleSet = require("../lib/RuleSet");
function match(ruleSet, resource) {

View File

@ -13,7 +13,9 @@ describe("WatchDetection", () => {
return;
}
for(let changeTimeout = 0; changeTimeout < 100; changeTimeout += 10) {
jest.setTimeout(10000);
for(let changeTimeout = 10; changeTimeout < 100; changeTimeout += 10) {
createTestCase(changeTimeout);
}
for(let changeTimeout = 200; changeTimeout <= 2000; changeTimeout += 200) {
@ -21,9 +23,7 @@ describe("WatchDetection", () => {
}
function createTestCase(changeTimeout) {
describe("time between changes " + changeTimeout + "ms", function() {
jest.setTimeout(10000);
describe(`time between changes ${changeTimeout}ms`, () => {
const fixturePath = path.join(__dirname, "fixtures", "temp-" + changeTimeout);
const filePath = path.join(fixturePath, "file.js");
const file2Path = path.join(fixturePath, "file2.js");

View File

@ -70,7 +70,7 @@ describe("WatchTestCases", () => {
fs.mkdirSync(dest);
});
categories.forEach((category) => {
before(() => {
beforeAll(() => {
const dest = path.join(__dirname, "js", "watch-src", category.name);
if(!fs.existsSync(dest))
fs.mkdirSync(dest);
@ -88,7 +88,9 @@ describe("WatchTestCases", () => {
suite: describe(name, () => {})
};
});
before(() => remove(tempDirectory));
beforeAll(() => {
remove(tempDirectory);
});
it("should compile", function(done) {
const outputDirectory = path.join(__dirname, "js", "watch", category.name, testName);

View File

@ -20,8 +20,8 @@ describe("main", function() {
expect(window.library2common.ok2).toEqual(expect.anything());
expect(window.library2common.ok2).toBe(true);
expect(window.library2).toEqual(expect.anything());
expect(window.toBeTruthy()).toEqual(expect.anything());
expect(window.toBeTruthy()).toBe(true);
expect(window.library2.ok).toEqual(expect.anything());
expect(window.library2.ok).toBe(true);
});
describe("web resolving", function() {
@ -32,7 +32,7 @@ describe("main", function() {
it("should load correct replacements for files", function(done) {
require.ensure(["subcontent"], function(require) {
// Comments work!
exports.toBeTruthy() = true;
exports.ok = true;
test(require("subcontent") === "replaced", "node_modules should be replaced with web_modules");
test(require("subcontent2/file.js") === "orginal", "node_modules should still work when web_modules exists");
done();
@ -40,8 +40,8 @@ describe("main", function() {
});
after(function() {
expect(exports.toBeTruthy()).toEqual(expect.anything());
expect(exports.toBeTruthy()).toBe(true);
expect(exports.ok).toEqual(expect.anything());
expect(exports.ok).toBe(true);
});
});

View File

@ -12,11 +12,6 @@ exports.default = new Promise (resolve, reject) ->
]
amd:
fromOptions: true
resolve:
# cannot resolve should outside the outermost node_modules
# so it is injected here
alias:
should: require.resolve "should"
plugins: [
new webpack.optimize.LimitChunkCountPlugin
maxChunks: 3

View File

@ -1,13 +1,11 @@
// Chunked File library
var should = require("should");
var library2commonValue = library2common;
describe("library2", function() {
var tickExtra, tickEmpty, tickMerged;
var extraValue, testValue;
before(function(done) {
beforeAll(function(done) {
var asnycOk = false, asnycOk2 = false;
var sameTick1 = true;
require.ensure(["./extra"], function(require) {

View File

@ -9,17 +9,3 @@ it("should support an empty context", function() {
}).toThrowError();
expect(c.keys()).toEqual([]);
});
// This would be a useful testcase, but it requires an (really) empty directory.
// **but** you cannot commit empty directories into git
/*it("should support an empty context (empty dir)", function() {
var c = require.context("./empty", true, /^nothing$/);
c.id.should.be.type("number");
(function() {
c.resolve("");
}).should.throw();
(function() {
c("");
}).should.throw();
expect(c.keys()).toEqual([]);
});*/

View File

@ -1,8 +1,8 @@
it("should not have commonjs stuff available", function() {
if(typeof module !== "undefined") { // If module is available
module.should.have.property("webpackTestSuiteModule"); // it must be the node.js module
expect(module).toHaveProperty("webpackTestSuiteModule"); // it must be the node.js module
}
if(typeof require !== "undefined") { // If require is available
require.should.have.property("webpackTestSuiteRequire"); // it must be the node.js require
expect(require).toHaveProperty("webpackTestSuiteRequire"); // it must be the node.js require
}
});

View File

@ -1,4 +1,3 @@
require("should");
const sinon = require("sinon");
const chunkLoadingSpy = sinon.spy(__webpack_require__, "e");

View File

@ -1,5 +1,3 @@
require("should");
var a = require("./a");
it("should run", function() {

View File

@ -1,4 +1 @@
require("should");
it("should run successful", function() {
});
it("should run successful", function() {});

View File

@ -1,5 +1,3 @@
require("should");
require("./common");
it("should have the correct main flag for multi first module", function() {

View File

@ -1,5 +1,3 @@
require("should");
require("./common");
it("should have the correct main flag for multi second module", function() {

View File

@ -1,5 +1,3 @@
require("should");
it("should have the correct main flag", function() {
var a = require("./vendor");
expect(a._main).toBe(false);

View File

@ -1,5 +1,3 @@
require("should");
var a = require("./a");
it("should run", function() {

View File

@ -1,5 +1,3 @@
require("should");
it("should run", function() {
var a = require("./a");
expect(a).toBe("a");

View File

@ -1,4 +1,3 @@
var should = require("should");
import d from "dll/d";
import { x1, y2 } from "./e";
import { x2, y1 } from "dll/e";

View File

@ -1,4 +1,3 @@
var should = require("should");
import d from "../0-create-dll/d";
import { x1, y2 } from "./e";
import { x2, y1 } from "../0-create-dll/e";

View File

@ -1,4 +1,3 @@
var should = require("should");
import d from "../0-create-dll/d";
import { x1, y2 } from "./e";
import { x2, y1 } from "../0-create-dll/e";
@ -28,5 +27,3 @@ it("should load an harmony module from dll (star export)", function() {
it("should load a module with loader applied", function() {
expect(require("../0-create-dll/g.abc.js")).toBe("number");
});

View File

@ -1,5 +1,3 @@
require("should");
it("should not load node-libs-browser when node option is false", function() {
expect((typeof process)).toBe("undefined");
});

View File

@ -1,5 +1,3 @@
require("should");
it("should add node-libs-browser to target web by default", function() {
expect(process.browser).toBe(true);
});

View File

@ -1,11 +1,3 @@
it("should provide a global Buffer shim", function () {
expect(Buffer).toBeInstanceOf(Function);
});
it("should fail on the buffer module"/*, function () {
(function(argument) {
try {
require("buffer");
} catch(e) { throw e; }
}).should.throw();
}*/);

View File

@ -1,7 +1,5 @@
"use strict";
require("should");
it("should be able to use global in strict mode", function() {
expect((typeof global)).toBe("object");
expect((global === null)).toBe(false)

View File

@ -5,14 +5,6 @@ it("should provide a global Buffer constructor", function() {
expect(Buffer).toBeInstanceOf(Function);
});
// Webpack is not providing a console shim by default
// @see lib/WebpackOptionsDefaulter.js
// Uncomment this when defaults are changed
//it("should provide a global console shim", function () {
// console.should.be.an.Object();
// console.time.should.be.a.Function();
//});
it("should provide a global process shim", function () {
expect(process).toBeInstanceOf(Object);
});

View File

@ -12,16 +12,13 @@ expect.extend({
` ${this.utils.printExpected(expected)}\n` +
"Received:\n" +
` ${this.utils.printReceived(objType)}`
: () => {
return (
this.utils.matcherHint(".toBeTypeOf") +
"\n\n" +
"Expected value to be (using typeof):\n" +
` ${this.utils.printExpected(expected)}\n` +
"Received:\n" +
` ${this.utils.printReceived(objType)}`
);
};
: () =>
this.utils.matcherHint(".toBeTypeOf") +
"\n\n" +
"Expected value to be (using typeof):\n" +
` ${this.utils.printExpected(expected)}\n` +
"Received:\n" +
` ${this.utils.printReceived(objType)}`;
return { message, pass };
}

View File

@ -4737,44 +4737,6 @@ shellwords@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
should-equal@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/should-equal/-/should-equal-1.0.1.tgz#0b6e9516f2601a9fb0bb2dcc369afa1c7e200af7"
dependencies:
should-type "^1.0.0"
should-format@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/should-format/-/should-format-3.0.3.tgz#9bfc8f74fa39205c53d38c34d717303e277124f1"
dependencies:
should-type "^1.3.0"
should-type-adaptors "^1.0.1"
should-type-adaptors@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz#401e7f33b5533033944d5cd8bf2b65027792e27a"
dependencies:
should-type "^1.3.0"
should-util "^1.0.0"
should-type@^1.0.0, should-type@^1.3.0, should-type@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/should-type/-/should-type-1.4.0.tgz#0756d8ce846dfd09843a6947719dfa0d4cff5cf3"
should-util@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/should-util/-/should-util-1.0.0.tgz#c98cda374aa6b190df8ba87c9889c2b4db620063"
should@^11.1.1:
version "11.2.1"
resolved "https://registry.yarnpkg.com/should/-/should-11.2.1.tgz#90f55145552d01cfc200666e4e818a1c9670eda2"
dependencies:
should-equal "^1.0.0"
should-format "^3.0.2"
should-type "^1.4.0"
should-type-adaptors "^1.0.1"
should-util "^1.0.0"
sigmund@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"