@@ -199,7 +199,7 @@ describe('Binary Control Operations', () => {
199199 it ( 'with localArgs, localIdentifier, localLoggingLevel' , ( ) => {
200200 const stateForBinary = {
201201 accessKey : 'someKey' ,
202- localArgs : '--arg1 val1 --arg2 val2' ,
202+ localArgs : [ '--arg1' , ' val1' , ' --arg2' , ' val2'] ,
203203 localIdentifier : 'someIdentifier' ,
204204 localLoggingLevel : 1 ,
205205 localTesting : 'start' ,
@@ -214,95 +214,99 @@ describe('Binary Control Operations', () => {
214214 os . platform ( ) ,
215215 'BrowserStackLocal_someJobName_now.log' ,
216216 ) ;
217- const expectedFinalArgs = `--key someKey --only-automate --ci-plugin GitHubAction --arg1 val1 --arg2 val2 --local-identifier someIdentifier --verbose 1 --log-file ${ expectedLogFilePath } ` ;
217+ const expectedFinalArgs = [
218+ '--key' , 'someKey' , '--only-automate' , '--ci-plugin' , 'GitHubAction' ,
219+ '--arg1' , 'val1' , '--arg2' , 'val2' ,
220+ '--local-identifier' , 'someIdentifier' , '--verbose' , '1' , '--log-file' , expectedLogFilePath ,
221+ ] ;
218222 const binaryControl = new BinaryControl ( stateForBinary ) ;
219223 binaryControl . _generateArgsForBinary ( ) ;
220- expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
224+ expect ( binaryControl . binaryArgs ) . to . deep . eq ( expectedFinalArgs ) ;
221225 } ) ;
222226
223227 it ( 'with localArgs, localIdentifier' , ( ) => {
224228 const stateForBinary = {
225229 accessKey : 'someKey' ,
226- localArgs : '--arg1 val1 --arg2 val2' ,
230+ localArgs : [ '--arg1' , ' val1' , ' --arg2' , ' val2'] ,
227231 localIdentifier : 'someIdentifier' ,
228232 localLoggingLevel : 0 ,
229233 localTesting : 'start' ,
230234 } ;
231235
232- const expectedFinalArgs = ` --key someKey --only-automate --ci-plugin GitHubAction --arg1 val1 --arg2 val2 --local-identifier someIdentifier ` ;
236+ const expectedFinalArgs = [ ' --key' , ' someKey' , ' --only-automate' , ' --ci-plugin' , ' GitHubAction' , ' --arg1' , ' val1' , ' --arg2' , ' val2' , ' --local-identifier' , ' someIdentifier' ] ;
233237 const binaryControl = new BinaryControl ( stateForBinary ) ;
234238 binaryControl . _generateArgsForBinary ( ) ;
235- expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
239+ expect ( binaryControl . binaryArgs ) . to . deep . eq ( expectedFinalArgs ) ;
236240 } ) ;
237241
238242 it ( 'with localArgs' , ( ) => {
239243 const stateForBinary = {
240244 accessKey : 'someKey' ,
241- localArgs : '--arg1 val1 --arg2 val2' ,
245+ localArgs : [ '--arg1' , ' val1' , ' --arg2' , ' val2'] ,
242246 localIdentifier : '' ,
243247 localLoggingLevel : 0 ,
244248 localTesting : 'start' ,
245249 } ;
246250
247- const expectedFinalArgs = ` --key someKey --only-automate --ci-plugin GitHubAction --arg1 val1 --arg2 val2 ` ;
251+ const expectedFinalArgs = [ ' --key' , ' someKey' , ' --only-automate' , ' --ci-plugin' , ' GitHubAction' , ' --arg1' , ' val1' , ' --arg2' , ' val2' ] ;
248252 const binaryControl = new BinaryControl ( stateForBinary ) ;
249253 binaryControl . _generateArgsForBinary ( ) ;
250- expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
254+ expect ( binaryControl . binaryArgs ) . to . deep . eq ( expectedFinalArgs ) ;
251255 } ) ;
252256
253257 it ( 'with the default args' , ( ) => {
254258 const stateForBinary = {
255259 accessKey : 'someKey' ,
256- localArgs : '' ,
260+ localArgs : [ ] ,
257261 localIdentifier : '' ,
258262 localLoggingLevel : 0 ,
259263 localTesting : 'start' ,
260264 } ;
261265
262- const expectedFinalArgs = ` --key someKey --only-automate --ci-plugin GitHubAction ` ;
266+ const expectedFinalArgs = [ ' --key' , ' someKey' , ' --only-automate' , ' --ci-plugin' , ' GitHubAction' ] ;
263267 const binaryControl = new BinaryControl ( stateForBinary ) ;
264268 binaryControl . _generateArgsForBinary ( ) ;
265- expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
269+ expect ( binaryControl . binaryArgs ) . to . deep . eq ( expectedFinalArgs ) ;
266270 } ) ;
267271 } ) ;
268272
269273 context ( 'Stop operation' , ( ) => {
270274 it ( 'with localIdentifier' , ( ) => {
271275 const stateForBinary = {
272276 accessKey : 'someKey' ,
273- localArgs : '' ,
277+ localArgs : [ ] ,
274278 localIdentifier : 'someIdentifier' ,
275279 localLoggingLevel : 0 ,
276280 localTesting : 'stop' ,
277281 } ;
278282
279- const expectedFinalArgs = ` --key someKey --only-automate --ci-plugin GitHubAction --local-identifier someIdentifier ` ;
283+ const expectedFinalArgs = [ ' --key' , ' someKey' , ' --only-automate' , ' --ci-plugin' , ' GitHubAction' , ' --local-identifier' , ' someIdentifier' ] ;
280284 const binaryControl = new BinaryControl ( stateForBinary ) ;
281285 binaryControl . _generateArgsForBinary ( ) ;
282- expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
286+ expect ( binaryControl . binaryArgs ) . to . deep . eq ( expectedFinalArgs ) ;
283287 } ) ;
284288
285289 it ( 'without localIdentifier' , ( ) => {
286290 const stateForBinary = {
287291 accessKey : 'someKey' ,
288- localArgs : '' ,
292+ localArgs : [ ] ,
289293 localIdentifier : '' ,
290294 localLoggingLevel : 0 ,
291295 localTesting : 'stop' ,
292296 } ;
293297
294- const expectedFinalArgs = ` --key someKey --only-automate --ci-plugin GitHubAction ` ;
298+ const expectedFinalArgs = [ ' --key' , ' someKey' , ' --only-automate' , ' --ci-plugin' , ' GitHubAction' ] ;
295299 const binaryControl = new BinaryControl ( stateForBinary ) ;
296300 binaryControl . _generateArgsForBinary ( ) ;
297- expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
301+ expect ( binaryControl . binaryArgs ) . to . deep . eq ( expectedFinalArgs ) ;
298302 } ) ;
299303 } ) ;
300304
301305 context ( 'Invalid Operation' , ( ) => {
302306 it ( 'Throws error in case its not start/stop' , ( ) => {
303307 const stateForBinary = {
304308 accessKey : 'someKey' ,
305- localArgs : '' ,
309+ localArgs : [ ] ,
306310 localIdentifier : 'someIdentifier' ,
307311 localLoggingLevel : 0 ,
308312 localTesting : 'someOperation' ,
@@ -322,7 +326,7 @@ describe('Binary Control Operations', () => {
322326 beforeEach ( ( ) => {
323327 sinon . stub ( exec , 'exec' ) ;
324328 binaryControl = new BinaryControl ( ) ;
325- binaryControl . binaryArgs = 'someArgs ' ;
329+ binaryControl . binaryArgs = [ 'someArgs' ] ;
326330 } ) ;
327331
328332 afterEach ( ( ) => {
@@ -331,7 +335,7 @@ describe('Binary Control Operations', () => {
331335
332336 it ( 'Start Operation' , async ( ) => {
333337 const response = await binaryControl . _triggerBinary ( LOCAL_TESTING . START ) ;
334- sinon . assert . calledWith ( exec . exec , ` ${ LOCAL_BINARY_NAME } someArgs --daemon start` ) ;
338+ sinon . assert . calledWith ( exec . exec , LOCAL_BINARY_NAME , [ ' someArgs' , ' --daemon' , ' start' ] ) ;
335339 expect ( response ) . to . eql ( {
336340 output : '' ,
337341 error : '' ,
@@ -340,7 +344,7 @@ describe('Binary Control Operations', () => {
340344
341345 it ( 'Stop Operation' , async ( ) => {
342346 const response = await binaryControl . _triggerBinary ( LOCAL_TESTING . STOP ) ;
343- sinon . assert . calledWith ( exec . exec , ` ${ LOCAL_BINARY_NAME } someArgs --daemon stop` ) ;
347+ sinon . assert . calledWith ( exec . exec , LOCAL_BINARY_NAME , [ ' someArgs' , ' --daemon' , ' stop' ] ) ;
344348 expect ( response ) . to . eql ( {
345349 output : '' ,
346350 error : '' ,
0 commit comments