Skip to content

Commit 79b30ba

Browse files
authored
Merge pull request webpack#4013 from shubheksha/refactor-test-DependenciesBlockVariable
refactor(ES6): DependenciesBlockVariable.test.js
2 parents d0908fe + aed6c04 commit 79b30ba

1 file changed

Lines changed: 32 additions & 40 deletions

File tree

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
var should = require("should");
2-
var sinon = require("sinon");
3-
var DependenciesBlockVariable = require("../lib/DependenciesBlockVariable");
1+
"use strict";
42

5-
describe("DependenciesBlockVariable", function() {
6-
var DependenciesBlockVariableInstance,
3+
const should = require("should");
4+
const sinon = require("sinon");
5+
const DependenciesBlockVariable = require("../lib/DependenciesBlockVariable");
6+
7+
describe("DependenciesBlockVariable", () => {
8+
let DependenciesBlockVariableInstance,
79
dependencyMock,
810
sandbox;
911

10-
before(function() {
12+
before(() => {
1113
sandbox = sinon.sandbox.create();
1214
dependencyMock = {
1315
constructor: {
@@ -21,54 +23,44 @@ describe("DependenciesBlockVariable", function() {
2123
"expression", [dependencyMock]);
2224
});
2325

24-
afterEach(function() {
25-
sandbox.restore();
26-
});
26+
afterEach(() => sandbox.restore());
2727

28-
describe("hasDependencies", function() {
29-
it("returns `true` if has dependencies", function() {
30-
should(DependenciesBlockVariableInstance.hasDependencies()).be.true();
31-
});
32-
});
28+
describe("hasDependencies", () =>
29+
it("returns `true` if has dependencies", () =>
30+
should(DependenciesBlockVariableInstance.hasDependencies()).be.true()));
3331

34-
describe("disconnect", function() {
35-
it("trigger dependencies disconnection", function() {
32+
describe("disconnect", () =>
33+
it("trigger dependencies disconnection", () => {
3634
DependenciesBlockVariableInstance.disconnect();
3735
should(dependencyMock.disconnect.calledOnce).be.true();
38-
});
39-
});
36+
}));
4037

41-
describe("updateHash", function() {
42-
var hash;
43-
before(function() {
38+
describe("updateHash", () => {
39+
let hash;
40+
before(() => {
4441
hash = {
4542
update: sandbox.spy()
4643
};
4744
DependenciesBlockVariableInstance.updateHash(hash);
4845
});
4946

50-
it("should update hash dependencies with name", function() {
51-
should(hash.update.calledWith("dependencies-name")).be.true();
52-
});
47+
it("should update hash dependencies with name", () =>
48+
should(hash.update.calledWith("dependencies-name")).be.true());
5349

54-
it("should update hash dependencies with expression", function() {
55-
should(hash.update.calledWith("expression")).be.true();
56-
});
50+
it("should update hash dependencies with expression", () =>
51+
should(hash.update.calledWith("expression")).be.true());
5752

58-
it("should update hash inside dependencies", function() {
59-
should(dependencyMock.updateHash.calledOnce).be.true();
60-
});
53+
it("should update hash inside dependencies", () =>
54+
should(dependencyMock.updateHash.calledOnce).be.true());
6155
});
6256

63-
describe("expressionSource", function() {
64-
var dependencyTemplates,
57+
describe("expressionSource", () => {
58+
let dependencyTemplates,
6559
applyMock;
6660

67-
before(function() {
68-
applyMock = sandbox.spy();
69-
});
61+
before(() => applyMock = sandbox.spy());
7062

71-
it("aplies information inside dependency templates", function() {
63+
it("aplies information inside dependency templates", () => {
7264
dependencyTemplates = {
7365
get: function() {
7466
return {
@@ -82,17 +74,17 @@ describe("DependenciesBlockVariable", function() {
8274
should(applyMock.calledOnce).be.true();
8375
});
8476

85-
it("aplies information inside dependency templates", function() {
77+
it("aplies information inside dependency templates", () => {
8678
dependencyTemplates = {
8779
get: function() {
8880
return false;
8981
}
9082
};
91-
should(function() {
83+
should(() => {
9284
DependenciesBlockVariableInstance.expressionSource(
9385
dependencyTemplates, {}, {}
94-
)
86+
);
9587
}).throw("No template for dependency: DependencyMock");
96-
})
88+
});
9789
});
9890
});

0 commit comments

Comments
 (0)