@@ -39,17 +39,21 @@ describe('closure-compiler node bindings', () => {
3939
4040 describe ( 'java version' , ( ) => {
4141 let originalTimeout ;
42- const compilerArgs = [
43- '-Xms2048m' ,
44- '--sun-misc-unsafe-memory-access=allow' ,
45- '-jar' ,
46- JAR_PATH ,
42+ const baseCompilerArgs = [
4743 '--one=true' ,
4844 '--two=two' ,
4945 '--three=one' ,
5046 '--three=two' ,
5147 '--three=three' ,
5248 ] ;
49+ const expandedCompilerArgs = [
50+ '-XX:+IgnoreUnrecognizedVMOptions' ,
51+ '--sun-misc-unsafe-memory-access=allow' ,
52+ '-jar' ,
53+ JAR_PATH ,
54+ ] . concat ( baseCompilerArgs ) ;
55+ const extraCompilerArgs = [ '-Xms2048m' ] ;
56+ const expandedPlusExtraArgs = extraCompilerArgs . concat ( expandedCompilerArgs ) ;
5357 beforeEach ( ( ) => {
5458 originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
5559 jasmine . DEFAULT_TIMEOUT_INTERVAL = 10000 ;
@@ -76,29 +80,26 @@ describe('closure-compiler node bindings', () => {
7680 expect ( hasRun ) . toBe ( true ) ;
7781 } ) ;
7882
79- it ( 'should normalize an options object to an arguments array' , async ( ) => {
83+ it ( 'should normalize an options object to an arguments array immediately' , ( ) => {
8084 const compiler = new Compiler ( {
8185 one : true ,
8286 two : 'two' ,
8387 three : [ 'one' , 'two' , 'three' ]
8488 } ) ;
85- await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
8689
87- const expectedArray = compilerArgs . slice ( 1 ) ;
88- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
90+ expect ( compiler . commandArguments . length ) . toBe ( baseCompilerArgs . length ) ;
8991 compiler . commandArguments . forEach ( ( item , index ) => {
90- expect ( expectedArray [ index ] ) . toBe ( item ) ;
92+ expect ( baseCompilerArgs [ index ] ) . toBe ( item ) ;
9193 } ) ;
9294 } ) ;
9395
9496 it ( 'should prepend the -jar argument and compiler path when configured by array' , async ( ) => {
95- const expectedArray = compilerArgs . slice ( 1 ) ;
96- const compiler = new Compiler ( expectedArray . slice ( 3 ) ) ;
97+ const compiler = new Compiler ( baseCompilerArgs ) ;
9798 await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
9899
99- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
100+ expect ( compiler . commandArguments . length ) . toBe ( expandedCompilerArgs . length ) ;
100101 compiler . commandArguments . forEach ( ( item , index ) => {
101- expect ( expectedArray [ index ] ) . toBe ( item ) ;
102+ expect ( expandedCompilerArgs [ index ] ) . toBe ( item ) ;
102103 } ) ;
103104 } ) ;
104105
@@ -109,23 +110,21 @@ describe('closure-compiler node bindings', () => {
109110 two : 'two' ,
110111 three : [ 'one' , 'two' , 'three' ] ,
111112 } ;
112- const expectedArray = compilerArgs ;
113- const compiler = new Compiler ( args , compilerArgs . slice ( 0 , 1 ) ) ;
113+ const compiler = new Compiler ( args , extraCompilerArgs ) ;
114114 await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
115115
116- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
116+ expect ( compiler . commandArguments . length ) . toBe ( expandedPlusExtraArgs . length ) ;
117117 compiler . commandArguments . forEach ( function ( item , index ) {
118- expect ( expectedArray [ index ] ) . toBe ( item ) ;
118+ expect ( expandedPlusExtraArgs [ index ] ) . toBe ( item ) ;
119119 } ) ;
120120 } ) ;
121121
122122 it ( 'should include initial command arguments when configured by array' , async ( ) => {
123- const expectedArray = compilerArgs ;
124- const compiler = new Compiler ( expectedArray . slice ( 4 ) , expectedArray . slice ( 0 , 1 ) ) ;
123+ const compiler = new Compiler ( baseCompilerArgs , extraCompilerArgs ) ;
125124 await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
126- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
125+ expect ( compiler . commandArguments . length ) . toBe ( expandedPlusExtraArgs . length ) ;
127126 compiler . commandArguments . forEach ( function ( item , index ) {
128- expect ( expectedArray [ index ] ) . toBe ( item ) ;
127+ expect ( expandedPlusExtraArgs [ index ] ) . toBe ( item ) ;
129128 } ) ;
130129 } ) ;
131130 } ) ;
0 commit comments