|
2 | 2 |
|
3 | 3 | const assert = require('assert');
|
4 | 4 | const addDevServerEntrypoints = require('../lib/util/addDevServerEntrypoints');
|
| 5 | +const config = require('./fixtures/simple-config/webpack.config'); |
5 | 6 |
|
6 | 7 | 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 | + |
7 | 50 | it('defaults to src if no entry point is given', () => {
|
8 | 51 | const webpackOptions = {};
|
9 | 52 | const devServerOptions = {};
|
|
0 commit comments