@@ -261,6 +261,98 @@ describe("options", () => {
261261
262262 } ) ;
263263 } ) ;
264+
265+ describe ( "setupOptions" , ( ) => {
266+ const testsWithNoHmrByDefault = [
267+ {
268+ name : "no nsconfig.json " ,
269+ isHmrEnabledByDefault : false ,
270+ args : [ ] ,
271+ expectedHmr : false ,
272+ expectedBundle : false
273+ } ,
274+ {
275+ name : "no nsconfig.json and --hmr is provided" ,
276+ isHmrEnabledByDefault : false ,
277+ args : [ "--hmr" ] ,
278+ expectedHmr : true ,
279+ expectedBundle : true
280+ } ,
281+ {
282+ name : "no nsconfig.json and --no-hmr is provided" ,
283+ isHmrEnabledByDefault : false ,
284+ args : [ "--no-hmr" ] ,
285+ expectedHmr : false ,
286+ expectedBundle : false
287+ } ,
288+ {
289+ name : "no nsconfig.json and --release is provided" ,
290+ isHmrEnabledByDefault : false ,
291+ args : [ "--release" ] ,
292+ expectedHmr : false ,
293+ expectedBundle : false
294+ } ,
295+ {
296+ name : "no nsconfig.json and --bundle is provided" ,
297+ isHmrEnabledByDefault : false ,
298+ args : [ "--bundle" ] ,
299+ expectedHmr : false ,
300+ expectedBundle : true
301+ }
302+ ] ;
303+ const testsWithHmrByDefault = < any > [
304+ {
305+ name : "has nsconfig.json" ,
306+ isHmrEnabledByDefault : true ,
307+ expectedHmr : true ,
308+ expectedBundle : true
309+ } ,
310+ {
311+ name : "has nsconfig.json and --hmr is provided" ,
312+ isHmrEnabledByDefault : true ,
313+ args : [ "--hmr" ] ,
314+ expectedHmr : true ,
315+ expectedBundle : true
316+ } ,
317+ {
318+ name : "has nsconfig.json and --no-hmr is provided" ,
319+ isHmrEnabledByDefault : true ,
320+ args : [ "--no-hmr" ] ,
321+ expectedHmr : false ,
322+ expectedBundle : false
323+ } ,
324+ {
325+ name : "has nsconfig.json and --release is provided" ,
326+ isHmrEnabledByDefault : true ,
327+ args : [ "--release" ] ,
328+ expectedHmr : false ,
329+ expectedBundle : true
330+ } ,
331+ {
332+ name : "has nsconfig.json and --bundle is provided" ,
333+ isHmrEnabledByDefault : true ,
334+ args : [ "--bundle" ] ,
335+ expectedHmr : true ,
336+ expectedBundle : true
337+ }
338+ ] ;
339+ const testCases = testsWithNoHmrByDefault . concat ( testsWithHmrByDefault ) ;
340+
341+ _ . each ( testCases , testCase => {
342+ it ( `should pass correctly when ${ testCase . name } ` , ( ) => {
343+ ( testCase . args || [ ] ) . forEach ( arg => process . argv . push ( arg ) ) ;
344+
345+ const options = createOptions ( testInjector ) ;
346+ const projectData = < IProjectData > { isHmrEnabledByDefault : testCase . isHmrEnabledByDefault } ;
347+ options . setupOptions ( projectData ) ;
348+
349+ ( testCase . args || [ ] ) . forEach ( arg => process . argv . pop ( ) ) ;
350+
351+ assert . equal ( ! ! options . argv . hmr , ! ! testCase . expectedHmr ) ;
352+ assert . equal ( ! ! options . argv . bundle , ! ! testCase . expectedBundle ) ;
353+ } ) ;
354+ } ) ;
355+ } ) ;
264356} ) ;
265357
266358function createOptionsWithProfileDir ( defaultProfileDir ?: string ) : IOptions {
0 commit comments