Skip to content

Commit ceed787

Browse files
committed
refactor(ES6): MultiStats.test.js
1 parent d9ac043 commit ceed787

1 file changed

Lines changed: 42 additions & 56 deletions

File tree

‎test/MultiStats.test.js‎

Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
var should = require("should");
2-
var sinon = require("sinon");
3-
var package = require("../package.json");
4-
var MultiStats = require("../lib/MultiStats");
1+
"use strict";
52

6-
var createStat = function(overides) {
3+
const should = require("should");
4+
const sinon = require("sinon");
5+
const packageJSON = require("../package.json");
6+
const MultiStats = require("../lib/MultiStats");
7+
8+
const createStat = function(overides) {
79
return Object.assign({
810
hash: "foo",
911
compilation: {
@@ -20,20 +22,18 @@ var createStat = function(overides) {
2022
}, overides);
2123
};
2224

23-
describe("MultiStats", function() {
24-
var packageVersion, stats, myMultiStats, result;
25+
describe("MultiStats", () => {
26+
let packageVersion, stats, myMultiStats, result;
2527

26-
beforeEach(function() {
27-
packageVersion = package.version;
28-
package.version = "1.2.3";
28+
beforeEach(() => {
29+
packageVersion = packageJSON.version;
30+
packageJSON.version = "1.2.3";
2931
});
3032

31-
afterEach(function() {
32-
package.version = packageVersion;
33-
});
33+
afterEach(() => packageJSON.version = packageVersion);
3434

35-
describe("created", function() {
36-
beforeEach(function() {
35+
describe("created", () => {
36+
beforeEach(() => {
3737
stats = [
3838
createStat({
3939
hash: "abc123"
@@ -45,14 +45,12 @@ describe("MultiStats", function() {
4545
myMultiStats = new MultiStats(stats);
4646
});
4747

48-
it("creates a hash string", function() {
49-
myMultiStats.hash.should.be.exactly("abc123xyz890");
50-
});
48+
it("creates a hash string", () => myMultiStats.hash.should.be.exactly("abc123xyz890"));
5149
});
5250

53-
describe("hasErrors", function() {
54-
describe("when both have errors", function() {
55-
beforeEach(function() {
51+
describe("hasErrors", () => {
52+
describe("when both have errors", () => {
53+
beforeEach(() => {
5654
stats = [
5755
createStat({
5856
hasErrors: () => true
@@ -64,13 +62,11 @@ describe("MultiStats", function() {
6462
myMultiStats = new MultiStats(stats);
6563
});
6664

67-
it("returns true", function() {
68-
myMultiStats.hasErrors().should.be.exactly(true);
69-
});
65+
it("returns true", () => myMultiStats.hasErrors().should.be.exactly(true));
7066
});
7167

72-
describe("when one has an error", function() {
73-
beforeEach(function() {
68+
describe("when one has an error", () => {
69+
beforeEach(() => {
7470
stats = [
7571
createStat({
7672
hasErrors: () => true
@@ -80,29 +76,25 @@ describe("MultiStats", function() {
8076
myMultiStats = new MultiStats(stats);
8177
});
8278

83-
it("returns true", function() {
84-
myMultiStats.hasErrors().should.be.exactly(true);
85-
});
79+
it("returns true", () => myMultiStats.hasErrors().should.be.exactly(true));
8680
});
8781

88-
describe("when none have errors", function() {
89-
beforeEach(function() {
82+
describe("when none have errors", () => {
83+
beforeEach(() => {
9084
stats = [
9185
createStat(),
9286
createStat()
9387
];
9488
myMultiStats = new MultiStats(stats);
9589
});
9690

97-
it("returns false", function() {
98-
myMultiStats.hasErrors().should.be.exactly(false);
99-
});
91+
it("returns false", () => myMultiStats.hasErrors().should.be.exactly(false));
10092
});
10193
});
10294

103-
describe("hasWarnings", function() {
104-
describe("when both have warnings", function() {
105-
beforeEach(function() {
95+
describe("hasWarnings", () => {
96+
describe("when both have warnings", () => {
97+
beforeEach(() => {
10698
stats = [
10799
createStat({
108100
hasWarnings: () => true
@@ -114,13 +106,11 @@ describe("MultiStats", function() {
114106
myMultiStats = new MultiStats(stats);
115107
});
116108

117-
it("returns true", function() {
118-
myMultiStats.hasWarnings().should.be.exactly(true);
119-
});
109+
it("returns true", () => myMultiStats.hasWarnings().should.be.exactly(true));
120110
});
121111

122-
describe("when one has a warning", function() {
123-
beforeEach(function() {
112+
describe("when one has a warning", () => {
113+
beforeEach(() => {
124114
stats = [
125115
createStat({
126116
hasWarnings: () => true
@@ -130,28 +120,24 @@ describe("MultiStats", function() {
130120
myMultiStats = new MultiStats(stats);
131121
});
132122

133-
it("returns true", function() {
134-
myMultiStats.hasWarnings().should.be.exactly(true);
135-
});
123+
it("returns true", () => myMultiStats.hasWarnings().should.be.exactly(true));
136124
});
137125

138-
describe("when none have warnings", function() {
139-
beforeEach(function() {
126+
describe("when none have warnings", () => {
127+
beforeEach(() => {
140128
stats = [
141129
createStat(),
142130
createStat()
143131
];
144132
myMultiStats = new MultiStats(stats);
145133
});
146134

147-
it("returns false", function() {
148-
myMultiStats.hasWarnings().should.be.exactly(false);
149-
});
135+
it("returns false", () => myMultiStats.hasWarnings().should.be.exactly(false));
150136
});
151137
});
152138

153-
describe("toJson", function() {
154-
beforeEach(function() {
139+
describe("toJson", () => {
140+
beforeEach(() => {
155141
stats = [
156142
createStat({
157143
hash: "abc123",
@@ -181,7 +167,7 @@ describe("MultiStats", function() {
181167
});
182168
});
183169

184-
it("returns plain object representation", function() {
170+
it("returns plain object representation", () => {
185171
result.should.deepEqual({
186172
errors: [
187173
"(abc123-compilation) abc123-error"
@@ -213,8 +199,8 @@ describe("MultiStats", function() {
213199
});
214200
});
215201

216-
describe("toString", function() {
217-
beforeEach(function() {
202+
describe("toString", () => {
203+
beforeEach(() => {
218204
stats = [
219205
createStat({
220206
hash: "abc123",
@@ -233,7 +219,7 @@ describe("MultiStats", function() {
233219
result = myMultiStats.toString();
234220
});
235221

236-
it("returns string representation", function() {
222+
it("returns string representation", () => {
237223
result.should.be.exactly(
238224
"Hash: abc123xyz890\n" +
239225
"Version: webpack 1.2.3\n" +

0 commit comments

Comments
 (0)