|
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"; |
6 | 2 |
|
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"); |
9 | 8 |
|
10 | | - beforeEach(function() { |
| 9 | +describe("JsonpHotUpdateChunkTemplatePlugin", () => { |
| 10 | + let handlerContext; |
| 11 | + |
| 12 | + beforeEach(() => |
11 | 13 | handlerContext = { |
12 | 14 | outputOptions: { |
13 | 15 | hotUpdateFunction: "Foo", |
14 | 16 | library: "Bar" |
15 | 17 | } |
16 | | - }; |
17 | | - }); |
| 18 | + }); |
18 | 19 |
|
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()); |
22 | 21 |
|
23 | | - describe("when applied", function() { |
24 | | - var eventBindings, eventBinding; |
| 22 | + describe("when applied", () => { |
| 23 | + let eventBindings, eventBinding; |
25 | 24 |
|
26 | | - beforeEach(function() { |
27 | | - eventBindings = applyPluginWithOptions(JsonpHotUpdateChunkTemplatePlugin); |
28 | | - }); |
| 25 | + beforeEach(() => eventBindings = applyPluginWithOptions(JsonpHotUpdateChunkTemplatePlugin)); |
29 | 26 |
|
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)); |
33 | 28 |
|
34 | | - describe("render handler", function() { |
35 | | - beforeEach(function() { |
36 | | - eventBinding = eventBindings[0]; |
37 | | - }); |
| 29 | + describe("render handler", () => { |
| 30 | + beforeEach(() => eventBinding = eventBindings[0]); |
38 | 31 |
|
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")); |
42 | 33 |
|
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); |
45 | 36 | source.should.be.instanceof(ConcatSource); |
46 | 37 | source.source().should.be.exactly("Foo(100,moduleSource())"); |
47 | 38 | }); |
48 | 39 | }); |
49 | 40 |
|
50 | | - describe("hash handler", function() { |
51 | | - var hashMock; |
| 41 | + describe("hash handler", () => { |
| 42 | + let hashMock; |
52 | 43 |
|
53 | | - beforeEach(function() { |
| 44 | + beforeEach(() => { |
54 | 45 | eventBinding = eventBindings[1]; |
55 | 46 | hashMock = { |
56 | 47 | update: sinon.spy() |
57 | 48 | }; |
58 | 49 | }); |
59 | 50 |
|
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")); |
63 | 52 |
|
64 | | - it("updates hash object", function() { |
| 53 | + it("updates hash object", () => { |
65 | 54 | eventBinding.handler.call(handlerContext, hashMock); |
66 | 55 | hashMock.update.callCount.should.be.exactly(4); |
67 | 56 | sinon.assert.calledWith(hashMock.update, "JsonpHotUpdateChunkTemplatePlugin"); |
|
0 commit comments