Skip to content
This repository was archived by the owner on Sep 9, 2021. It is now read-only.

Commit a811e05

Browse files
committedFeb 21, 2017
Fix test lint
1 parent f91e7bf commit a811e05

File tree

6 files changed

+49
-34
lines changed

6 files changed

+49
-34
lines changed
 

‎.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
test/fixtures
12
test/expected

‎package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@
1010
"eslintConfig": {
1111
"extends": "webpack",
1212
"rules": {
13-
"linebreak-style": 0
13+
"linebreak-style": 0,
14+
"comma-dangle": [
15+
"error",
16+
{
17+
"arrays": "always-multiline",
18+
"objects": "always-multiline",
19+
"imports": "always-multiline",
20+
"exports": "always-multiline",
21+
"functions": "never"
22+
}
23+
]
1424
}
1525
},
1626
"peerDependencies": {

‎test/fixtures/inline/entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import Worker from '../../../index.js?inline!./worker.js';
1+
const Worker = require('../../../index.js?inline!./worker.js');

‎test/fixtures/name/entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import Worker from '../../../index.js?name=namedWorker.js!./worker.js';
1+
const Worker = require('../../../index.js?name=namedWorker.js!./worker.js');

‎test/fixtures/worker/entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import Worker from '../../../index.js!./worker.js';
1+
const Worker = require('../../../index.js!./worker.js');

‎test/index.js

+34-30
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,59 @@ process.chdir(__dirname);
77

88
const readFile = file => fs.readFileSync(file, 'utf-8');
99

10-
const makeBundle = name => {
11-
return del(`expected/${name}`).then(() => {
12-
const bundle = webpack({
13-
entry: `./fixtures/${name}/entry.js`,
14-
output: {
15-
path: `expected/${name}`,
16-
filename: 'bundle.js'
10+
const makeBundle = name => del(`expected/${name}`).then(() => {
11+
const bundle = webpack({
12+
entry: `./fixtures/${name}/entry.js`,
13+
output: {
14+
path: `expected/${name}`,
15+
filename: 'bundle.js',
16+
},
17+
});
18+
return new Promise((resolve, reject) => {
19+
bundle.run((err, stats) => {
20+
if (err) {
21+
reject(err);
22+
} else {
23+
resolve(stats);
1724
}
1825
});
19-
return new Promise((resolve, reject) => {
20-
bundle.run((err, stats) => err ? reject(err) : resolve(stats))
21-
});
2226
});
23-
};
27+
});
2428

2529
describe('worker-loader', () => {
26-
it('should create chunk with worker', () => {
27-
return makeBundle('worker').then(stats => {
28-
const workerFile = stats.toJson('minimal').children
30+
it('should create chunk with worker', () =>
31+
makeBundle('worker').then((stats) => {
32+
const [workerFile] = stats.toJson('minimal').children
2933
.map(item => item.chunks)
3034
.reduce((acc, item) => acc.concat(item), [])
3135
.map(item => item.files)
32-
.map(item => 'expected/worker/' + item)[0];
36+
.map(item => `expected/worker/${item}`);
3337
assert(workerFile);
3438
assert.notEqual(readFile(workerFile).indexOf('// worker test mark'), -1);
35-
});
36-
});
39+
})
40+
);
3741

38-
it('should create chunk with specified name', () => {
39-
return makeBundle('name').then(stats => {
40-
const workerFile = 'expected/name/namedWorker.js'
41-
const receivedWorkerFile = stats.toJson('minimal').children
42+
it('should create chunk with specified name', () =>
43+
makeBundle('name').then((stats) => {
44+
const workerFile = 'expected/name/namedWorker.js';
45+
const [receivedWorkerFile] = stats.toJson('minimal').children
4246
.map(item => item.chunks)
4347
.reduce((acc, item) => acc.concat(item), [])
4448
.map(item => item.files)
45-
.map(item => 'expected/name/' + item)[0];
49+
.map(item => `expected/name/${item}`);
4650
assert.equal(receivedWorkerFile, workerFile);
4751
assert.notEqual(readFile(workerFile).indexOf('// named worker test mark'), -1);
48-
});
49-
});
52+
})
53+
);
5054

51-
it('should inline worker with inline option', () => {
52-
return makeBundle('inline').then(stats => {
53-
const bundleFile = stats.toJson('minimal').chunks
55+
it('should inline worker with inline option', () =>
56+
makeBundle('inline').then((stats) => {
57+
const [bundleFile] = stats.toJson('minimal').chunks
5458
.map(item => item.files)
5559
.reduce((acc, item) => acc.concat(item), [])
56-
.map(item => 'expected/inline/' + item)[0];
60+
.map(item => `expected/inline/${item}`);
5761
assert(bundleFile);
5862
assert.notEqual(readFile(bundleFile).indexOf('// inlined worker test mark'), -1);
59-
});
60-
});
63+
})
64+
);
6165
});

0 commit comments

Comments
 (0)
This repository has been archived.