Skip to content

Commit d62fc03

Browse files
committed
refactor(ES6): Chunk.test.js
1 parent 0b47602 commit d62fc03

1 file changed

Lines changed: 47 additions & 68 deletions

File tree

test/Chunk.test.js

Lines changed: 47 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,85 @@
1-
var should = require("should");
2-
var path = require("path");
3-
var Chunk = require("../lib/Chunk");
1+
"use strict";
42

5-
describe("Chunk", function() {
6-
var ChunkInstance;
3+
const should = require("should");
4+
const path = require("path");
5+
const Chunk = require("../lib/Chunk");
76

8-
beforeEach(function() {
9-
ChunkInstance = new Chunk("chunk-test", "module-test", "loc-test");
10-
});
7+
describe("Chunk", () => {
8+
let ChunkInstance;
119

12-
it("should have debugId more than 100", function() {
13-
should(ChunkInstance.debugId).be.above(100);
14-
});
10+
beforeEach(() => ChunkInstance = new Chunk("chunk-test", "module-test", "loc-test"));
1511

16-
it("returns a string with modules information", function() {
17-
should(ChunkInstance.toString()).be.exactly("Chunk[]");
18-
})
12+
it("should have debugId more than 100", () => should(ChunkInstance.debugId).be.above(100));
1913

20-
it("should have origins based in constructor information", function() {
14+
it("returns a string with modules information", () => should(ChunkInstance.toString()).be.exactly("Chunk[]"));
15+
16+
it("should have origins based in constructor information", () =>
2117
should(ChunkInstance.origins[0]).be.eql({
2218
module: "module-test",
2319
loc: "loc-test",
2420
name: "chunk-test"
25-
})
26-
});
21+
}));
2722

28-
it("should not be the initial instance", function() {
29-
should(ChunkInstance.isInitial()).be.false();
30-
});
23+
it("should not be the initial instance", () => should(ChunkInstance.isInitial()).be.false());
3124

32-
describe("entry", function() {
33-
it("returns an error if get entry", function() {
34-
should(function() {
35-
var entryTest = ChunkInstance.entry;
36-
}).throw("Chunk.entry was removed. Use hasRuntime()");
37-
});
25+
describe("entry", () => {
26+
it("returns an error if get entry", () =>
27+
should(() => {
28+
const entryTest = ChunkInstance.entry;
29+
}).throw("Chunk.entry was removed. Use hasRuntime()"));
3830

39-
it("returns an error if set an entry", function() {
40-
should(function() {
31+
it("returns an error if set an entry", () =>
32+
should(() => {
4133
ChunkInstance.entry = 10;
42-
}).throw("Chunk.entry was removed. Use hasRuntime()");
43-
});
34+
}).throw("Chunk.entry was removed. Use hasRuntime()"));
4435
});
4536

46-
describe("initial", function() {
47-
it("returns an error if get initial", function() {
48-
should(function() {
49-
var initialTest = ChunkInstance.initial;
50-
}).throw("Chunk.initial was removed. Use isInitial()");
51-
});
37+
describe("initial", () => {
38+
it("returns an error if get initial", () =>
39+
should(() => {
40+
const initialTest = ChunkInstance.initial;
41+
}).throw("Chunk.initial was removed. Use isInitial()"));
5242

53-
it("returns an error if set an initial", function() {
54-
should(function() {
43+
it("returns an error if set an initial", () =>
44+
should(() => {
5545
ChunkInstance.initial = 10;
56-
}).throw("Chunk.initial was removed. Use isInitial()");
57-
});
46+
}).throw("Chunk.initial was removed. Use isInitial()"));
5847
});
5948

60-
describe("hasRuntime", function() {
61-
it("returns false", function() {
62-
should(ChunkInstance.hasRuntime()).be.false();
63-
});
49+
describe("hasRuntime", () => {
50+
it("returns false", () => should(ChunkInstance.hasRuntime()).be.false());
6451
});
6552

66-
describe("isEmpty", function() {
67-
it("should NOT have any module by default", function() {
68-
should(ChunkInstance.isEmpty()).be.true();
69-
});
53+
describe("isEmpty", () => {
54+
it("should NOT have any module by default", () => should(ChunkInstance.isEmpty()).be.true());
7055
});
7156

72-
describe("size", function() {
73-
it("should NOT have any module by default", function() {
57+
describe("size", () => {
58+
it("should NOT have any module by default", () =>
7459
should(ChunkInstance.size({
7560
chunkOverhead: 10,
7661
entryChunkMultiplicator: 2
77-
})).be.exactly(10);
78-
});
62+
})).be.exactly(10));
7963
});
8064

81-
describe("checkConstraints", function() {
82-
it("throws an error", function() {
83-
should(function() {
65+
describe("checkConstraints", () => {
66+
it("throws an error", () =>
67+
should(() => {
8468
ChunkInstance.checkConstraints();
85-
}).not.throw(/checkConstraints/);
86-
});
69+
}).not.throw(/checkConstraints/));
8770
});
8871

89-
describe("canBeIntegrated", function() {
90-
it("returns `false` if other object is initial", function() {
91-
var other = {
92-
isInitial: function() {
93-
return true
94-
}
72+
describe("canBeIntegrated", () => {
73+
it("returns `false` if other object is initial", () => {
74+
const other = {
75+
isInitial: () => true
9576
};
9677
should(ChunkInstance.canBeIntegrated(other)).be.false();
9778
});
9879

99-
it("returns `true` if other object and chunk instance are NOT initial", function() {
100-
var other = {
101-
isInitial: function() {
102-
return false
103-
}
80+
it("returns `true` if other object and chunk instance are NOT initial", () => {
81+
const other = {
82+
isInitial: () => false
10483
};
10584
should(ChunkInstance.canBeIntegrated(other)).be.true();
10685
});

0 commit comments

Comments
 (0)