@@ -4,7 +4,7 @@ const assert = require('assert');
4
4
const addDevServerEntrypoints = require ( '../lib/util/addDevServerEntrypoints' ) ;
5
5
const config = require ( './fixtures/simple-config/webpack.config' ) ;
6
6
7
- describe ( 'Entry' , ( ) => {
7
+ describe . only ( 'Entry' , ( ) => {
8
8
it ( 'adds devServer entry points to a single entry point' , ( ) => {
9
9
const webpackOptions = Object . assign ( { } , config ) ;
10
10
const devServerOptions = { } ;
@@ -56,4 +56,58 @@ describe('Entry', () => {
56
56
assert . equal ( webpackOptions . entry . length , 2 ) ;
57
57
assert . equal ( webpackOptions . entry [ 1 ] , './src' ) ;
58
58
} ) ;
59
+
60
+ it ( 'preserves dynamic entry points' , ( done ) => {
61
+ let i = 0 ;
62
+ const webpackOptions = {
63
+ // simulate dynamic entry
64
+ entry : ( ) => {
65
+ i += 1 ;
66
+ return `./src-${ i } .js` ;
67
+ }
68
+ } ;
69
+ const devServerOptions = { } ;
70
+
71
+ addDevServerEntrypoints ( webpackOptions , devServerOptions ) ;
72
+
73
+ assert ( typeof webpackOptions . entry , 'function' ) ;
74
+
75
+ webpackOptions . entry ( ) . then ( entryFirstRun => (
76
+ webpackOptions . entry ( ) . then ( ( entrySecondRun ) => {
77
+ assert . equal ( entryFirstRun . length , 2 ) ;
78
+ assert . equal ( entryFirstRun [ 1 ] , './src-1.js' ) ;
79
+
80
+ assert . equal ( entrySecondRun . length , 2 ) ;
81
+ assert . equal ( entrySecondRun [ 1 ] , './src-2.js' ) ;
82
+ done ( ) ;
83
+ } )
84
+ ) ) . catch ( done ) ;
85
+ } ) ;
86
+
87
+ it ( 'preserves asynchronous dynamic entry points' , ( done ) => {
88
+ let i = 0 ;
89
+ const webpackOptions = {
90
+ // simulate async dynamic entry
91
+ entry : ( ) => new Promise ( ( resolve ) => {
92
+ i += 1 ;
93
+ resolve ( `./src-${ i } .js` ) ;
94
+ } )
95
+ } ;
96
+ const devServerOptions = { } ;
97
+
98
+ addDevServerEntrypoints ( webpackOptions , devServerOptions ) ;
99
+
100
+ assert ( typeof webpackOptions . entry , 'function' ) ;
101
+
102
+ webpackOptions . entry ( ) . then ( entryFirstRun => (
103
+ webpackOptions . entry ( ) . then ( ( entrySecondRun ) => {
104
+ assert . equal ( entryFirstRun . length , 2 ) ;
105
+ assert . equal ( entryFirstRun [ 1 ] , './src-1.js' ) ;
106
+
107
+ assert . equal ( entrySecondRun . length , 2 ) ;
108
+ assert . equal ( entrySecondRun [ 1 ] , './src-2.js' ) ;
109
+ done ( ) ;
110
+ } )
111
+ ) ) . catch ( done ) ;
112
+ } ) ;
59
113
} ) ;
0 commit comments