Skip to content

Commit 1e8f92a

Browse files
authored
Merge pull request webpack#4021 from shubheksha/refactor-test-JsonpHotUpdateChunkTemplatePlugin
refactor(ES6): JsonpHotUpdateChunkTemplatePlugin.test.js
2 parents 78ff5f9 + 8bb25db commit 1e8f92a

1 file changed

Lines changed: 26 additions & 37 deletions

File tree

test/JsonpHotUpdateChunkTemplatePlugin.test.js

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,56 @@
1-
var should = require("should");
2-
var sinon = require("sinon");
3-
var ConcatSource = require("webpack-sources").ConcatSource;
4-
var JsonpHotUpdateChunkTemplatePlugin = require("../lib/JsonpHotUpdateChunkTemplatePlugin");
5-
var applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
1+
"use strict";
62

7-
describe("JsonpHotUpdateChunkTemplatePlugin", function() {
8-
var handlerContext;
3+
const should = require("should");
4+
const sinon = require("sinon");
5+
const ConcatSource = require("webpack-sources").ConcatSource;
6+
const JsonpHotUpdateChunkTemplatePlugin = require("../lib/JsonpHotUpdateChunkTemplatePlugin");
7+
const applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
98

10-
beforeEach(function() {
9+
describe("JsonpHotUpdateChunkTemplatePlugin", () => {
10+
let handlerContext;
11+
12+
beforeEach(() =>
1113
handlerContext = {
1214
outputOptions: {
1315
hotUpdateFunction: "Foo",
1416
library: "Bar"
1517
}
16-
};
17-
});
18+
});
1819

19-
it("has apply function", function() {
20-
(new JsonpHotUpdateChunkTemplatePlugin()).apply.should.be.a.Function();
21-
});
20+
it("has apply function", () => (new JsonpHotUpdateChunkTemplatePlugin()).apply.should.be.a.Function());
2221

23-
describe("when applied", function() {
24-
var eventBindings, eventBinding;
22+
describe("when applied", () => {
23+
let eventBindings, eventBinding;
2524

26-
beforeEach(function() {
27-
eventBindings = applyPluginWithOptions(JsonpHotUpdateChunkTemplatePlugin);
28-
});
25+
beforeEach(() => eventBindings = applyPluginWithOptions(JsonpHotUpdateChunkTemplatePlugin));
2926

30-
it("binds two event handlers", function() {
31-
eventBindings.length.should.be.exactly(2);
32-
});
27+
it("binds two event handlers", () => eventBindings.length.should.be.exactly(2));
3328

34-
describe("render handler", function() {
35-
beforeEach(function() {
36-
eventBinding = eventBindings[0];
37-
});
29+
describe("render handler", () => {
30+
beforeEach(() => eventBinding = eventBindings[0]);
3831

39-
it("binds to render event", function() {
40-
eventBinding.name.should.be.exactly("render");
41-
});
32+
it("binds to render event", () => eventBinding.name.should.be.exactly("render"));
4233

43-
it("creates source wrapper with export", function() {
44-
var source = eventBinding.handler.call(handlerContext, "moduleSource()", [], [], {}, 100);
34+
it("creates source wrapper with export", () => {
35+
const source = eventBinding.handler.call(handlerContext, "moduleSource()", [], [], {}, 100);
4536
source.should.be.instanceof(ConcatSource);
4637
source.source().should.be.exactly("Foo(100,moduleSource())");
4738
});
4839
});
4940

50-
describe("hash handler", function() {
51-
var hashMock;
41+
describe("hash handler", () => {
42+
let hashMock;
5243

53-
beforeEach(function() {
44+
beforeEach(() => {
5445
eventBinding = eventBindings[1];
5546
hashMock = {
5647
update: sinon.spy()
5748
};
5849
});
5950

60-
it("binds to hash event", function() {
61-
eventBinding.name.should.be.exactly("hash");
62-
});
51+
it("binds to hash event", () => eventBinding.name.should.be.exactly("hash"));
6352

64-
it("updates hash object", function() {
53+
it("updates hash object", () => {
6554
eventBinding.handler.call(handlerContext, hashMock);
6655
hashMock.update.callCount.should.be.exactly(4);
6756
sinon.assert.calledWith(hashMock.update, "JsonpHotUpdateChunkTemplatePlugin");

0 commit comments

Comments
 (0)