Skip to content

Commit 3034914

Browse files
committed
Add tests for each type of entry option
1 parent 4bee993 commit 3034914

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/Entry.test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,51 @@
22

33
const assert = require('assert');
44
const addDevServerEntrypoints = require('../lib/util/addDevServerEntrypoints');
5+
const config = require('./fixtures/simple-config/webpack.config');
56

67
describe('Entry', () => {
8+
it('adds devServer entry points to a single entry point', () => {
9+
const webpackOptions = Object.assign({}, config);
10+
const devServerOptions = {};
11+
12+
addDevServerEntrypoints(webpackOptions, devServerOptions);
13+
14+
assert.equal(webpackOptions.entry.length, 2);
15+
assert(webpackOptions.entry[0].indexOf('client/index.js?') !== -1);
16+
assert.equal(webpackOptions.entry[1], './foo.js');
17+
});
18+
19+
it('adds devServer entry points to a multi-module entry point', () => {
20+
const webpackOptions = Object.assign({}, config, {
21+
entry: ['./foo.js', './bar.js']
22+
});
23+
const devServerOptions = {};
24+
25+
addDevServerEntrypoints(webpackOptions, devServerOptions);
26+
27+
assert.equal(webpackOptions.entry.length, 3);
28+
assert(webpackOptions.entry[0].indexOf('client/index.js?') !== -1);
29+
assert.equal(webpackOptions.entry[1], './foo.js');
30+
assert.equal(webpackOptions.entry[2], './bar.js');
31+
});
32+
33+
it('adds devServer entry points to a multi entry point object', () => {
34+
const webpackOptions = Object.assign({}, config, {
35+
entry: {
36+
foo: './foo.js',
37+
bar: './bar.js'
38+
}
39+
});
40+
const devServerOptions = {};
41+
42+
addDevServerEntrypoints(webpackOptions, devServerOptions);
43+
44+
assert.equal(webpackOptions.entry.foo.length, 2);
45+
assert(webpackOptions.entry.foo[0].indexOf('client/index.js?') !== -1);
46+
assert.equal(webpackOptions.entry.foo[1], './foo.js');
47+
assert.equal(webpackOptions.entry.bar[1], './bar.js');
48+
});
49+
750
it('defaults to src if no entry point is given', () => {
851
const webpackOptions = {};
952
const devServerOptions = {};

0 commit comments

Comments
 (0)