Skip to content

Commit 242e37b

Browse files
authored
Merge pull request webpack#3730 from timse/fix-global-leak-in-requirejsstuff-test
Fix global leak in requirejsstuff test
2 parents c44f75d + e73cbf3 commit 242e37b

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

test/RequireJsStuffPlugin.test.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
var should = require("should");
2-
var sinon = require("sinon");
3-
var RequireJsStuffPlugin = require("../lib/RequireJsStuffPlugin");
4-
var applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
5-
var PluginEnvironment = require("./helpers/PluginEnvironment");
1+
"use strict";
2+
const should = require("should");
3+
const sinon = require("sinon");
4+
const RequireJsStuffPlugin = require("../lib/RequireJsStuffPlugin");
5+
const applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
6+
const PluginEnvironment = require("./helpers/PluginEnvironment");
67

78
describe("RequireJsStuffPlugin", function() {
89
it("has apply function", function() {
910
(new RequireJsStuffPlugin()).apply.should.be.a.Function();
1011
});
1112

1213
describe("when applied", function() {
13-
var eventBindings, eventBinding;
14+
let eventBindings;
15+
let eventBinding;
1416

1517
beforeEach(function() {
1618
eventBindings = applyPluginWithOptions(RequireJsStuffPlugin);
@@ -30,7 +32,9 @@ describe("RequireJsStuffPlugin", function() {
3032
});
3133

3234
describe('when called', function() {
33-
var pluginEnvironment, compilationEventBindings, compilation;
35+
let pluginEnvironment;
36+
let compilationEventBindings;
37+
let compilation;
3438

3539
beforeEach(function() {
3640
pluginEnvironment = new PluginEnvironment();
@@ -42,7 +46,7 @@ describe("RequireJsStuffPlugin", function() {
4246
set: sinon.spy()
4347
}
4448
};
45-
var params = {
49+
const params = {
4650
normalModuleFactory: pluginEnvironment.getEnvironmentStub()
4751
};
4852
eventBinding.handler(compilation, params);
@@ -62,7 +66,9 @@ describe("RequireJsStuffPlugin", function() {
6266
});
6367

6468
describe("parser handler", function() {
65-
var parser, parserEventBindings;
69+
let parser;
70+
let parserEventBindings;
71+
let compilationEventBinding;
6672

6773
beforeEach(function() {
6874
compilationEventBinding = compilationEventBindings[0];
@@ -88,7 +94,9 @@ describe("RequireJsStuffPlugin", function() {
8894
});
8995

9096
describe('when called with empty parser options', function() {
91-
var parserEventBinding, parserEventContext, expressionMock;
97+
let parserEventBinding;
98+
let parserEventContext;
99+
let expressionMock;
92100

93101
beforeEach(function() {
94102
parserEventContext = {
@@ -148,8 +156,8 @@ describe("RequireJsStuffPlugin", function() {
148156
});
149157

150158
it('adds dependency to current state', function() {
151-
var addDependencySpy = parserEventContext.state.current.addDependency;
152-
var addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
159+
const addDependencySpy = parserEventContext.state.current.addDependency;
160+
const addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
153161
addDependencySpy.callCount.should.be.exactly(1);
154162
addedDependency.should.be.exactly('{"module":null,"expression":";","range":10,"loc":5}');
155163
});
@@ -171,8 +179,8 @@ describe("RequireJsStuffPlugin", function() {
171179
});
172180

173181
it('adds dependency to current state', function() {
174-
var addDependencySpy = parserEventContext.state.current.addDependency;
175-
var addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
182+
const addDependencySpy = parserEventContext.state.current.addDependency;
183+
const addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
176184
addDependencySpy.callCount.should.be.exactly(1);
177185
addedDependency.should.be.exactly('{"module":null,"expression":"\\"0.0.0\\"","range":10,"loc":5}');
178186
});
@@ -194,8 +202,8 @@ describe("RequireJsStuffPlugin", function() {
194202
});
195203

196204
it('adds dependency to current state', function() {
197-
var addDependencySpy = parserEventContext.state.current.addDependency;
198-
var addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
205+
const addDependencySpy = parserEventContext.state.current.addDependency;
206+
const addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
199207
addDependencySpy.callCount.should.be.exactly(1);
200208
addedDependency.should.be.exactly('{"module":null,"expression":"\\"__webpack_require__.oe\\"","range":10,"loc":5}');
201209
});

0 commit comments

Comments
 (0)