Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit fe166b7

Browse files
committed
style: Consistent spacing and lint fixes
1 parent 337ee36 commit fe166b7

File tree

1 file changed

+48
-45
lines changed

1 file changed

+48
-45
lines changed

test/webpack-integration.test.js

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,57 @@
1-
/* eslint-disable */
2-
import fs from "fs";
3-
import vm from "vm";
4-
import path from "path";
5-
import webpack from "webpack";
1+
/* eslint-disable import/no-dynamic-require, global-require */
2+
import fs from 'fs';
3+
import path from 'path';
4+
import webpack from 'webpack';
65
import ExtractTextPlugin from '../src';
76

8-
var cases = process.env.CASES ? process.env.CASES.split(",") : fs.readdirSync(path.join(__dirname, "cases"));
7+
const cases = process.env.CASES ? process.env.CASES.split(',') : fs.readdirSync(path.join(__dirname, 'cases'));
98

10-
describe("Webpack Integration Tests", function() {
11-
cases.forEach(function(testCase) {
12-
it(testCase, function(done) {
13-
var testDirectory = path.join(__dirname, "cases", testCase);
14-
var outputDirectory = path.join(__dirname, "js", testCase);
15-
var options = { entry: { test: "./index.js" } };
16-
var configFile = path.join(testDirectory, "webpack.config.js");
17-
if(fs.existsSync(configFile))
18-
options = require(configFile);
19-
options.context = testDirectory;
20-
if(!options.module) options.module = {};
21-
if(!options.module.loaders) options.module.loaders = [
22-
{ test: /\.txt$/, loader: ExtractTextPlugin.extract('raw-loader') }
23-
];
24-
if(!options.output) options.output = { filename: "[name].js" };
25-
if(!options.output.path) options.output.path = outputDirectory;
26-
if(process.env.CASES) {
27-
console.log("\nwebpack." + testCase + ".config.js " + JSON.stringify(options, null, 2));
28-
}
29-
webpack(options, function(err, stats) {
30-
if(err) return done(err);
31-
if(stats.hasErrors()) return done(new Error(stats.toString()));
32-
var testFile = path.join(outputDirectory, "test.js");
33-
if(fs.existsSync(testFile))
34-
require(testFile)(suite);
35-
var expectedDirectory = path.join(testDirectory, "expected");
36-
fs.readdirSync(expectedDirectory).forEach(function(file) {
37-
var filePath = path.join(expectedDirectory, file);
38-
var actualPath = path.join(outputDirectory, file);
9+
describe('Webpack Integration Tests', () => {
10+
cases.forEach((testCase) => {
11+
it(testCase, (done) => {
12+
let options = { entry: { test: './index.js' } };
13+
const testDirectory = path.join(__dirname, 'cases', testCase);
14+
const outputDirectory = path.join(__dirname, 'js', testCase);
15+
const configFile = path.join(testDirectory, 'webpack.config.js');
16+
17+
if (fs.existsSync(configFile)) {
18+
options = require(configFile);
19+
}
20+
options.context = testDirectory;
21+
if (!options.module) options.module = {};
22+
if (!options.module.loaders) {
23+
options.module.loaders = [{ test: /\.txt$/, loader: ExtractTextPlugin.extract('raw-loader') }];
24+
}
25+
if (!options.output) options.output = { filename: '[name].js' };
26+
if (!options.output.path) options.output.path = outputDirectory;
27+
if (process.env.CASES) {
28+
console.log(`\nwebpack.${testCase}.config.js ${JSON.stringify(options, null, 2)}`);
29+
}
30+
31+
webpack(options, (err, stats) => {
32+
if (err) return done(err);
33+
if (stats.hasErrors()) return done(new Error(stats.toString()));
34+
const testFile = path.join(outputDirectory, 'test.js');
35+
if (fs.existsSync(testFile)) {
36+
require(testFile)(suite);
37+
}
38+
const expectedDirectory = path.join(testDirectory, 'expected');
39+
fs.readdirSync(expectedDirectory).forEach((file) => {
40+
const filePath = path.join(expectedDirectory, file);
41+
const actualPath = path.join(outputDirectory, file);
3942
expect(readFileOrEmpty(actualPath)).toEqual(readFileOrEmpty(filePath));
4043
expect(readFileOrEmpty(actualPath)).toMatchSnapshot();
41-
});
42-
done();
43-
});
44-
});
45-
});
44+
});
45+
done();
46+
});
47+
});
48+
});
4649
});
4750

4851
function readFileOrEmpty(path) {
49-
try {
50-
return fs.readFileSync(path, "utf-8");
51-
} catch(e) {
52-
return "";
53-
}
52+
try {
53+
return fs.readFileSync(path, 'utf-8');
54+
} catch (e) {
55+
return '';
56+
}
5457
}

0 commit comments

Comments
 (0)