Skip to content

Commit 5a8083a

Browse files
committed
migrate should to expect, part 1
used regexps: ([\(\)a-zA-Z0-9\."'/ +{}\[\]=\-,:?_!]+)\.should\.be\.eql ➡️ expect($1).toBe expect\(([\(\)a-zA-Z0-9\."'/ +{}\[\]=\-,:?_!]+)\)\.toBe\(\[ ➡️ expect($1).toEqual([ expect\(([\(\)a-zA-Z0-9\."'/ +{}\[\]=\-,:?_!]+)\)\.toBe\(\{ ➡️ expect($1).toEqual({
1 parent 009772c commit 5a8083a

File tree

242 files changed

+923
-923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+923
-923
lines changed

test/ExternalModule.unittest.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe("ExternalModule", () => {
6060
expect(externalModule.getSource.callCount).toBe(1);
6161
expect(externalModule.getSourceString.callCount).toBe(1);
6262
expect(externalModule.getSource.args[0][0]).toBe(expectedString);
63-
expect(result).toBe(expectedSource);
63+
expect(result).toEqual(expectedSource);
6464
});
6565
});
6666

@@ -77,7 +77,7 @@ describe("ExternalModule", () => {
7777
const result = externalModule.getSource(someSourceString);
7878

7979
// check
80-
expect(result).toBeInstanceOf(OriginalSource);
80+
expect(result).toEqualInstanceOf(OriginalSource);
8181
});
8282
});
8383
describe("given it does not use source maps", () => {
@@ -92,7 +92,7 @@ describe("ExternalModule", () => {
9292
const result = externalModule.getSource(someSourceString);
9393

9494
// check
95-
expect(result).toBeInstanceOf(RawSource);
95+
expect(result).toEqualInstanceOf(RawSource);
9696
});
9797
});
9898
});
@@ -109,7 +109,7 @@ describe("ExternalModule", () => {
109109
const result = externalModule.getSourceForGlobalVariableExternal(varName, type);
110110

111111
// check
112-
expect(result).toBe(expected);
112+
expect(result).toEqual(expected);
113113
});
114114
});
115115
describe("given an single variable name", () => {
@@ -123,7 +123,7 @@ describe("ExternalModule", () => {
123123
const result = externalModule.getSourceForGlobalVariableExternal(varName, type);
124124

125125
// check
126-
expect(result).toBe(expected);
126+
expect(result).toEqual(expected);
127127
});
128128
});
129129
});
@@ -139,7 +139,7 @@ describe("ExternalModule", () => {
139139
const result = externalModule.getSourceForCommonJsExternal(varName, type);
140140

141141
// check
142-
expect(result).toBe(expected);
142+
expect(result).toEqual(expected);
143143
});
144144
});
145145
describe("given an single variable name", () => {
@@ -153,7 +153,7 @@ describe("ExternalModule", () => {
153153
const result = externalModule.getSourceForCommonJsExternal(varName, type);
154154

155155
// check
156-
expect(result).toBe(expected);
156+
expect(result).toEqual(expected);
157157
});
158158
});
159159
});
@@ -170,7 +170,7 @@ describe("ExternalModule", () => {
170170
const result = externalModule.checkExternalVariable(variableToCheck, request);
171171

172172
// check
173-
expect(result).toBe(expected);
173+
expect(result).toEqual(expected);
174174
});
175175
});
176176

@@ -185,7 +185,7 @@ describe("ExternalModule", () => {
185185
const result = externalModule.getSourceForAmdOrUmdExternal(id, optional, request);
186186

187187
// check
188-
expect(result).toBe(expected);
188+
expect(result).toEqual(expected);
189189
});
190190
describe("given an optinal check is set", () => {
191191
it("ads a check for the existance of the variable before looking it up", () => {
@@ -199,7 +199,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_someId__;`;
199199
const result = externalModule.getSourceForAmdOrUmdExternal(id, optional, request);
200200

201201
// check
202-
expect(result).toBe(expected);
202+
expect(result).toEqual(expected);
203203
});
204204
});
205205
});
@@ -214,7 +214,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_someId__;`;
214214
const result = externalModule.getSourceForDefaultCase(optional, request);
215215

216216
// check
217-
expect(result).toBe(expected);
217+
expect(result).toEqual(expected);
218218
});
219219
describe("given an optinal check is requested", () => {
220220
it("checks for the existance of the request setting it", () => {
@@ -227,7 +227,7 @@ module.exports = some/request;`;
227227
const result = externalModule.getSourceForDefaultCase(optional, request);
228228

229229
// check
230-
expect(result).toBe(expected);
230+
expect(result).toEqual(expected);
231231
});
232232
});
233233
});

test/MultiStats.unittest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ describe("MultiStats", () => {
263263
});
264264

265265
it("returns string representation", () => {
266-
expect(result).toBe(
266+
expect(result).toEqual(
267267
"Hash: abc123xyz890\n" +
268268
"Version: webpack 1.2.3\n" +
269269
"Child abc123-compilation:\n" +

test/cases/amd/namedModules/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ define("named4", [], function() {
1616

1717
define(["named1", "named2"], function(named1, named2) {
1818
it("should load the named modules in defined dependencies", function() {
19-
named1.should.be.eql("named1");
20-
named2.should.be.eql("named2");
19+
expect(named1).toBe("named1");
20+
expect(named2).toBe("named2");
2121
});
2222

2323
it("should load the named modules in require dependencies", function(done) {
2424
require(["named3", "named4"], function (named3, named4) {
25-
named3.should.be.eql("named3");
26-
named4.should.be.eql("named4");
25+
expect(named3).toBe("named3");
26+
expect(named4).toBe("named4");
2727
done();
2828
});
2929
});

test/cases/amd/namedModulesConstArrayDep/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ define("named4", [], function() {
1616

1717
define("named1,named2".split(","), function(named1, named2) {
1818
it("should load the named modules in const array defined dependencies", function() {
19-
named1.should.be.eql("named1");
20-
named2.should.be.eql("named2");
19+
expect(named1).toBe("named1");
20+
expect(named2).toBe("named2");
2121
});
2222

2323
it("should load the named modules in const array require dependencies", function(done) {
2424
require("named3,named4".split(","), function (named3, named4) {
25-
named3.should.be.eql("named3");
26-
named4.should.be.eql("named4");
25+
expect(named3).toBe("named3");
26+
expect(named4).toBe("named4");
2727
done();
2828
});
2929
});

test/cases/chunks/circular-correctness/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ it("should handle circular chunks correctly", function(done) {
22
import(/* webpackChunkName: "a" */"./module-a").then(function(result) {
33
return result.default();
44
}).then(function(result2) {
5-
result2.default().should.be.eql("x");
5+
expect(result2.default()).toBe("x");
66
done();
77
}).catch(function(e) {
88
done(e);

test/cases/chunks/context-weak/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ it("should not bundle context requires with asyncMode === 'weak'", function() {
77

88
it("should find module with asyncMode === 'weak' when required elsewhere", function() {
99
var contextRequire = require.context(".", false, /.+/, "weak");
10-
contextRequire("./three").should.be.eql(3);
10+
expect(contextRequire("./three")).toBe(3);
1111
require("./three"); // in a real app would be served as a separate chunk
1212
});
1313

1414
it("should find module with asyncMode === 'weak' when required elsewhere (recursive)", function() {
1515
var contextRequire = require.context(".", true, /.+/, "weak");
16-
contextRequire("./dir/four").should.be.eql(4);
16+
expect(contextRequire("./dir/four")).toBe(4);
1717
require("./dir/four"); // in a real app would be served as a separate chunk
1818
});

test/cases/chunks/context/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
it("should also work in a chunk", function(done) {
22
require.ensure([], function(require) {
33
var contextRequire = require.context(".", false, /two/);
4-
contextRequire("./two").should.be.eql(2);
4+
expect(contextRequire("./two")).toBe(2);
55
var tw = "tw";
6-
require("." + "/" + tw + "o").should.be.eql(2);
6+
expect(require("." + "/" + tw + "o")).toBe(2);
77
done();
88
});
99
});

test/cases/chunks/import-context/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ function testCase(load, done) {
22
load("two", 2, function() {
33
var sync = true;
44
load("one", 1, function() {
5-
sync.should.be.eql(false);
5+
expect(sync).toBe(false);
66
load("three", 3, function() {
77
var sync = true;
88
load("two", 2, function() {
9-
sync.should.be.eql(true);
9+
expect(sync).toBe(true);
1010
done();
1111
});
1212
Promise.resolve().then(function() {}).then(function() {}).then(function() {
@@ -23,7 +23,7 @@ function testCase(load, done) {
2323
it("should be able to use expressions in import", function(done) {
2424
function load(name, expected, callback) {
2525
import("./dir/" + name).then(function(result) {
26-
result.should.be.eql({ default: expected });
26+
expect(result).toEqual({ default: expected });
2727
callback();
2828
}).catch(function(err) {
2929
done(err);

test/cases/chunks/import/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
it("should be able to use import", function(done) {
22
import("./two").then(function(two) {
3-
two.should.be.eql({ default: 2 });
3+
expect(two).toEqual({ default: 2 });
44
done();
55
}).catch(function(err) {
66
done(err);

test/cases/chunks/inline-options/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ function testChunkLoading(load, expectedSyncInitial, expectedSyncRequested) {
106106
var sync = false;
107107
var syncInitial = true;
108108
var p = Promise.all([load("a"), load("b")]).then(function() {
109-
syncInitial.should.be.eql(expectedSyncInitial);
109+
expect(syncInitial).toBe(expectedSyncInitial);
110110
sync = true;
111111
var p = Promise.all([
112112
load("a").then(function(a) {
113-
a.should.be.eql({ default: "a" });
114-
sync.should.be.eql(true);
113+
expect(a).toEqual({ default: "a" });
114+
expect(sync).toBe(true);
115115
}),
116116
load("c").then(function(c) {
117-
c.should.be.eql({ default: "c" });
118-
sync.should.be.eql(expectedSyncRequested);
117+
expect(c).toEqual({ default: "c" });
118+
expect(sync).toBe(expectedSyncRequested);
119119
})
120120
]);
121121
Promise.resolve().then(function(){}).then(function(){}).then(function(){}).then(function(){

0 commit comments

Comments
 (0)