Skip to content

Commit 0a6b452

Browse files
authored
Merge pull request webpack#4042 from shubheksha/refactor-test-RawModule
refactor(ES6): RawModule.test.js
2 parents 59e88b9 + a1a4e82 commit 0a6b452

1 file changed

Lines changed: 47 additions & 43 deletions

File tree

test/RawModule.test.js

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,65 @@
1-
var RawModule = require("../lib/RawModule");
2-
var OriginalSource = require("webpack-sources").OriginalSource;
3-
var RawSource = require("webpack-sources").RawSource;
4-
var RequestShortener = require("../lib/RequestShortener");
5-
var should = require("should");
6-
var path = require("path")
7-
8-
describe("RawModule", function() {
9-
var myRawModule;
10-
11-
before(function() {
12-
var source = 'sourceStr attribute';
13-
var identifier = 'identifierStr attribute';
14-
var readableIdentifier = 'readableIdentifierStr attribute';
1+
"use strict";
2+
3+
const RawModule = require("../lib/RawModule");
4+
const OriginalSource = require("webpack-sources").OriginalSource;
5+
const RawSource = require("webpack-sources").RawSource;
6+
const RequestShortener = require("../lib/RequestShortener");
7+
const should = require("should");
8+
const path = require("path");
9+
10+
describe("RawModule", () => {
11+
let myRawModule;
12+
13+
before(() => {
14+
const source = "sourceStr attribute";
15+
const identifier = "identifierStr attribute";
16+
const readableIdentifier = "readableIdentifierStr attribute";
1517
myRawModule = new RawModule(source, identifier, readableIdentifier);
1618
});
1719

18-
describe('identifier', function() {
19-
it('returns value for identifierStr attribute', function() {
20-
should(myRawModule.identifier()).be.exactly('identifierStr attribute');
21-
});
20+
describe("identifier", () => {
21+
it("returns value for identifierStr attribute", () =>
22+
should(myRawModule.identifier()).be.exactly("identifierStr attribute"));
2223
});
2324

24-
describe('size', function() {
25-
it('returns value for sourceStr attribute\'s length property', function() {
26-
var sourceStrLength = myRawModule.sourceStr.length;
25+
describe("size", () => {
26+
it("returns value for sourceStr attribute\"s length property", () => {
27+
const sourceStrLength = myRawModule.sourceStr.length;
2728
should(myRawModule.size()).be.exactly(sourceStrLength);
2829
});
2930
});
3031

31-
describe('readableIdentifier', function() {
32-
it('returns result of calling provided requestShortener\'s shorten method\
33-
on readableIdentifierStr attribute', function() {
34-
var requestShortener = new RequestShortener(path.resolve());
35-
should.exist(myRawModule.readableIdentifier(requestShortener));
36-
});
32+
describe("readableIdentifier", () => {
33+
it("returns result of calling provided requestShortener\"s shorten method " +
34+
"on readableIdentifierStr attribute",
35+
() => {
36+
const requestShortener = new RequestShortener(path.resolve());
37+
should.exist(myRawModule.readableIdentifier(requestShortener));
38+
}
39+
);
3740
});
3841

39-
describe('needRebuild', function() {
40-
it('returns false', function() {
41-
should(myRawModule.needRebuild()).be.false();
42-
});
42+
describe("needRebuild", () => {
43+
it("returns false", () => should(myRawModule.needRebuild()).be.false());
4344
});
4445

45-
describe('source', function() {
46-
it('returns a new OriginalSource instance with sourceStr attribute and\
47-
return value of identifier() function provided as constructor arguments',
48-
function() {
49-
var originalSource = new OriginalSource(myRawModule.sourceStr, myRawModule.identifier());
46+
describe("source", () => {
47+
it("returns a new OriginalSource instance with sourceStr attribute and " +
48+
"return value of identifier() function provided as constructor arguments",
49+
() => {
50+
const originalSource = new OriginalSource(myRawModule.sourceStr, myRawModule.identifier());
5051
myRawModule.useSourceMap = true;
5152
myRawModule.source().should.match(originalSource);
52-
});
53+
}
54+
);
5355

54-
it('returns a new RawSource instance with sourceStr attribute provided\
55-
as constructor argument if useSourceMap is falsey', function() {
56-
var rawSource = new RawSource(myRawModule.sourceStr);
57-
myRawModule.useSourceMap = false;
58-
myRawModule.source().should.match(rawSource);
59-
});
56+
it("returns a new RawSource instance with sourceStr attribute provided " +
57+
"as constructor argument if useSourceMap is falsey",
58+
() => {
59+
const rawSource = new RawSource(myRawModule.sourceStr);
60+
myRawModule.useSourceMap = false;
61+
myRawModule.source().should.match(rawSource);
62+
}
63+
);
6064
});
6165
});

0 commit comments

Comments
 (0)