Skip to content

Commit 105d970

Browse files
authored
Merge pull request webpack#4052 from shubheksha/refactor-test-WarnCaseSensitiveModulesPlugin
refactor(ES6): WarnCaseSensitiveModulesPlugin.test.js
2 parents 4e93849 + 4d22880 commit 105d970

1 file changed

Lines changed: 24 additions & 34 deletions

File tree

test/WarnCaseSensitiveModulesPlugin.test.js

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,39 @@
1-
var should = require("should");
2-
var sinon = require("sinon");
3-
var PluginEnvironment = require("./helpers/PluginEnvironment");
4-
var applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
5-
var WarnCaseSensitiveModulesPlugin = require("../lib/WarnCaseSensitiveModulesPlugin");
1+
"use strict";
62

7-
describe("WarnCaseSensitiveModulesPlugin", function() {
8-
var env;
3+
const should = require("should");
4+
const sinon = require("sinon");
5+
const PluginEnvironment = require("./helpers/PluginEnvironment");
6+
const applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
7+
const WarnCaseSensitiveModulesPlugin = require("../lib/WarnCaseSensitiveModulesPlugin");
98

10-
beforeEach(function() {
11-
env = {};
12-
});
9+
describe("WarnCaseSensitiveModulesPlugin", () => {
10+
let env;
1311

14-
it("has apply function", function() {
15-
(new WarnCaseSensitiveModulesPlugin()).apply.should.be.a.Function();
16-
});
12+
beforeEach(() => env = {});
1713

18-
describe("when applied", function() {
19-
beforeEach(function() {
20-
env.eventBindings = applyPluginWithOptions(WarnCaseSensitiveModulesPlugin);
21-
});
14+
it("has apply function", () =>
15+
(new WarnCaseSensitiveModulesPlugin()).apply.should.be.a.Function());
2216

23-
it("binds one event handler", function() {
24-
env.eventBindings.length.should.be.exactly(1);
25-
});
17+
describe("when applied", () => {
18+
beforeEach(() => env.eventBindings = applyPluginWithOptions(WarnCaseSensitiveModulesPlugin));
2619

27-
describe("compilation handler", function() {
28-
beforeEach(function() {
20+
it("binds one event handler", () => env.eventBindings.length.should.be.exactly(1));
21+
22+
describe("compilation handler", () => {
23+
beforeEach(() => {
2924
env.pluginEnvironment = new PluginEnvironment();
3025
env.eventBinding = env.eventBindings[0];
3126
env.eventBinding.handler(env.pluginEnvironment.getEnvironmentStub());
3227
env.compilationEventBindings = env.pluginEnvironment.getEventBindings();
3328
});
3429

35-
it("binds to compilation event", function() {
36-
env.eventBinding.name.should.be.exactly("compilation");
37-
});
30+
it("binds to compilation event", () =>
31+
env.eventBinding.name.should.be.exactly("compilation"));
3832

39-
it("binds one compilation event handler", function() {
40-
env.compilationEventBindings.length.should.be.exactly(1);
41-
});
33+
it("binds one compilation event handler", () => env.compilationEventBindings.length.should.be.exactly(1));
4234

43-
describe("seal handler", function() {
44-
beforeEach(function() {
35+
describe("seal handler", () => {
36+
beforeEach(() => {
4537
env.compilationEventContext = {
4638
modules: [{
4739
identifier: () => "Foo",
@@ -62,11 +54,9 @@ describe("WarnCaseSensitiveModulesPlugin", function() {
6254
env.compilationEventBinding.handler.call(env.compilationEventContext);
6355
});
6456

65-
it("binds to seal event", function() {
66-
env.compilationEventBinding.name.should.be.exactly("seal");
67-
});
57+
it("binds to seal event", () => env.compilationEventBinding.name.should.be.exactly("seal"));
6858

69-
it("adds warning for each plugin with case insensitive name", function() {
59+
it("adds warning for each plugin with case insensitive name", () => {
7060
env.compilationEventContext.warnings.length.should.be.exactly(1);
7161
env.compilationEventContext.warnings[0].message.should.be.exactly(`
7262
There are multiple modules with names that only differ in casing.

0 commit comments

Comments
 (0)