@@ -1234,7 +1234,7 @@ describe('utils', () => {
12341234 sandbox . restore ( ) ;
12351235 } ) ;
12361236
1237- it ( 'if local is true and localIdentifier is not running and start error is raised' , ( ) => {
1237+ it ( 'if local is true and localBinary is not running and start error is raised' , ( ) => {
12381238 let bsConfig = {
12391239 auth : {
12401240 access_key : 'xyz' ,
@@ -1245,11 +1245,11 @@ describe('utils', () => {
12451245 } ,
12461246 } ;
12471247 let args = { } ;
1248- let checkLocalIdentifierRunningStub = sinon . stub (
1248+ let checkLocalBinaryRunningStub = sinon . stub (
12491249 utils ,
1250- 'checkLocalIdentifierRunning '
1250+ 'checkLocalBinaryRunning '
12511251 ) ;
1252- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( false ) ) ;
1252+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : true } ) ) ;
12531253 let setLocalArgsStub = sinon . stub ( utils , 'setLocalArgs' ) ;
12541254 setLocalArgsStub . returns ( { } ) ;
12551255 let localBinaryStartStub = sandbox
@@ -1270,7 +1270,7 @@ describe('utils', () => {
12701270 } ) ;
12711271 } ) ;
12721272
1273- it ( 'if local is true and localIdentifier is not running and start error is not raised' , ( ) => {
1273+ it ( 'if local is true and localBinary is not running and start error is not raised' , ( ) => {
12741274 let bsConfig = {
12751275 auth : {
12761276 access_key : 'xyz' ,
@@ -1286,11 +1286,11 @@ describe('utils', () => {
12861286 localIdentifier : 'abc' ,
12871287 daemon : true ,
12881288 } ;
1289- let checkLocalIdentifierRunningStub = sinon . stub (
1289+ let checkLocalBinaryRunningStub = sinon . stub (
12901290 utils ,
1291- 'checkLocalIdentifierRunning '
1291+ 'checkLocalBinaryRunning '
12921292 ) ;
1293- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( false ) ) ;
1293+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : true } ) ) ;
12941294 let setLocalArgsStub = sinon . stub ( utils , 'setLocalArgs' ) ;
12951295 setLocalArgsStub . returns ( localArgs ) ;
12961296
@@ -1322,11 +1322,11 @@ describe('utils', () => {
13221322 } ,
13231323 } ;
13241324 let args = { } ;
1325- let checkLocalIdentifierRunningStub = sinon . stub (
1325+ let checkLocalBinaryRunningStub = sinon . stub (
13261326 utils ,
1327- 'checkLocalIdentifierRunning '
1327+ 'checkLocalBinaryRunning '
13281328 ) ;
1329- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1329+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
13301330 return utils . setupLocalTesting ( bsConfig , args ) . then ( ( result ) => {
13311331 expect ( result ) . to . be . eq ( undefined ) ;
13321332 } ) ;
@@ -1373,19 +1373,19 @@ describe('utils', () => {
13731373 local : true ,
13741374 } ,
13751375 } ;
1376- let checkLocalIdentifierRunningStub = sinon . stub (
1376+ let checkLocalBinaryRunningStub = sinon . stub (
13771377 utils ,
1378- 'checkLocalIdentifierRunning '
1378+ 'checkLocalBinaryRunning '
13791379 ) ;
1380- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( false ) ) ;
1380+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : true } ) ) ;
13811381 let sendUsageReportStub = sandbox
13821382 . stub ( utils , 'sendUsageReport' )
13831383 . callsFake ( function ( ) {
13841384 return 'end' ;
13851385 } ) ;
1386- return utils . stopLocalBinary ( bsConfig ) . then ( ( result ) => {
1386+ return utils . stopLocalBinary ( bsConfig , null , null , null ) . then ( ( result ) => {
13871387 expect ( result ) . to . be . eq ( undefined ) ;
1388- sinon . assert . calledOnce ( sendUsageReportStub ) ;
1388+ sinon . assert . notCalled ( sendUsageReportStub ) ;
13891389 } ) ;
13901390 } ) ;
13911391
@@ -1399,11 +1399,11 @@ describe('utils', () => {
13991399 let bs_local = {
14001400 isRunning : isRunningStub ,
14011401 } ;
1402- let checkLocalIdentifierRunningStub = sinon . stub (
1402+ let checkLocalBinaryRunningStub = sinon . stub (
14031403 utils ,
1404- 'checkLocalIdentifierRunning '
1404+ 'checkLocalBinaryRunning '
14051405 ) ;
1406- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1406+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
14071407 return utils . stopLocalBinary ( bsConfig , bs_local ) . then ( ( result ) => {
14081408 expect ( result ) . to . be . eq ( undefined ) ;
14091409 } ) ;
@@ -1419,11 +1419,11 @@ describe('utils', () => {
14191419 let bs_local = {
14201420 isRunning : isRunningStub ,
14211421 } ;
1422- let checkLocalIdentifierRunningStub = sinon . stub (
1422+ let checkLocalBinaryRunningStub = sinon . stub (
14231423 utils ,
1424- 'checkLocalIdentifierRunning '
1424+ 'checkLocalBinaryRunning '
14251425 ) ;
1426- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1426+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
14271427 return utils . stopLocalBinary ( bsConfig , bs_local ) . then ( ( result ) => {
14281428 expect ( result ) . to . be . eq ( undefined ) ;
14291429 } ) ;
@@ -1441,11 +1441,11 @@ describe('utils', () => {
14411441 isRunning : isRunningStub ,
14421442 stop : stopStub ,
14431443 } ;
1444- let checkLocalIdentifierRunningStub = sinon . stub (
1444+ let checkLocalBinaryRunningStub = sinon . stub (
14451445 utils ,
1446- 'checkLocalIdentifierRunning '
1446+ 'checkLocalBinaryRunning '
14471447 ) ;
1448- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1448+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
14491449 return utils . stopLocalBinary ( bsConfig , bs_local ) . then ( ( result ) => {
14501450 expect ( result ) . to . be . eq ( undefined ) ;
14511451 } ) ;
@@ -1460,11 +1460,11 @@ describe('utils', () => {
14601460 let isRunningStub = sandbox . stub ( ) . returns ( true ) ;
14611461 let error = new Error ( 'Local Stop Error' ) ;
14621462 let stopStub = sandbox . stub ( ) . yields ( error ) ;
1463- let checkLocalIdentifierRunningStub = sinon . stub (
1463+ let checkLocalBinaryRunningStub = sinon . stub (
14641464 utils ,
1465- 'checkLocalIdentifierRunning '
1465+ 'checkLocalBinaryRunning '
14661466 ) ;
1467- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1467+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
14681468 let bs_local = {
14691469 isRunning : isRunningStub ,
14701470 stop : stopStub ,
@@ -1503,7 +1503,7 @@ describe('utils', () => {
15031503 afterEach ( function ( ) {
15041504 delete process . env . BROWSERSTACK_LOCAL_IDENTIFIER ;
15051505 } ) ;
1506- it ( 'should generate local_identifier if args.localIdentifier & process.env.BROWSERSTACK_LOCAL_IDENTIFIER is undefined' , ( ) => {
1506+ it ( 'should not generate local_identifier if args.localIdentifier & process.env.BROWSERSTACK_LOCAL_IDENTIFIER is undefined' , ( ) => {
15071507 let bsConfig = {
15081508 connection_settings : {
15091509 local : true ,
@@ -1516,7 +1516,8 @@ describe('utils', () => {
15161516 ) ;
15171517 generateLocalIdentifierStub . returns ( 'abc' ) ;
15181518 utils . setLocalIdentifier ( bsConfig , args ) ;
1519- expect ( bsConfig . connection_settings . local_identifier ) . to . be . eq ( 'abc' ) ;
1519+ sinon . assert . notCalled ( generateLocalIdentifierStub ) ;
1520+ expect ( bsConfig . connection_settings . local_identifier ) . to . be . eq ( undefined ) ;
15201521 } ) ;
15211522
15221523 it ( 'should change local identifier to local_identifier in bsConfig if process.env.BROWSERSTACK_LOCAL_IDENTIFIER is set to local_identifier' , ( ) => {
@@ -2392,7 +2393,7 @@ describe('utils', () => {
23922393 } ) ;
23932394 } ) ;
23942395
2395- describe ( '#checkLocalIdentifierRunning ' , ( ) => {
2396+ describe ( '#checkLocalBinaryRunning ' , ( ) => {
23962397 afterEach ( ( ) => {
23972398 sinon . restore ( ) ;
23982399 } ) ;
@@ -2404,21 +2405,10 @@ describe('utils', () => {
24042405 } ,
24052406 } ;
24062407 const responseBody = {
2407- status : 'success' ,
2408- instances : [
2409- {
2410- localIdentifier : 'abcdef' ,
2411- } ,
2412- {
2413- localIdentifier : 'ghij' ,
2414- } ,
2415- {
2416- localIdentifier : 'lmno' ,
2417- } ,
2418- ] ,
2408+ "should_spawn_binary" : true
24192409 } ;
24202410 sinon
2421- . stub ( request , 'get ' )
2411+ . stub ( request , 'post ' )
24222412 . yields ( undefined , responseObject , JSON . stringify ( responseBody ) ) ;
24232413
24242414 let bsConfig = {
@@ -2430,35 +2420,22 @@ describe('utils', () => {
24302420
24312421 let localIdentifier = 'abcd' ;
24322422 return utils
2433- . checkLocalIdentifierRunning ( bsConfig , localIdentifier )
2423+ . checkLocalBinaryRunning ( bsConfig , localIdentifier )
24342424 . then ( ( result ) => {
2435- expect ( result ) . to . be . eq ( false ) ;
2425+ chai . assert . deepEqual ( result , { "should_spawn_binary" : true } ) ;
24362426 } ) ;
24372427 } ) ;
24382428
2439- it ( 'if the bsConfig localIdentifier if present within the response body then the function should resolve with true ' , ( ) => {
2429+ it ( 'if the bsConfig localIdentifier is present within the response body' , ( ) => {
24402430 const responseObject = {
24412431 statusCode : 200 ,
24422432 headers : {
24432433 'content-type' : 'application/json' ,
24442434 } ,
24452435 } ;
2446- const responseBody = {
2447- status : 'success' ,
2448- instances : [
2449- {
2450- localIdentifier : 'abcdef' ,
2451- } ,
2452- {
2453- localIdentifier : 'ghij' ,
2454- } ,
2455- {
2456- localIdentifier : 'lmno' ,
2457- } ,
2458- ] ,
2459- } ;
2436+ const responseBody = { "should_spawn_binary" : false } ;
24602437 sinon
2461- . stub ( request , 'get ' )
2438+ . stub ( request , 'post ' )
24622439 . yields ( undefined , responseObject , JSON . stringify ( responseBody ) ) ;
24632440
24642441 let bsConfig = {
@@ -2470,9 +2447,9 @@ describe('utils', () => {
24702447
24712448 let localIdentifier = 'lmno' ;
24722449 return utils
2473- . checkLocalIdentifierRunning ( bsConfig , localIdentifier )
2450+ . checkLocalBinaryRunning ( bsConfig , localIdentifier )
24742451 . then ( ( result ) => {
2475- expect ( result ) . to . be . eq ( true ) ;
2452+ chai . assert . deepEqual ( result , { "should_spawn_binary" : false } )
24762453 } ) ;
24772454 } ) ;
24782455 } ) ;
0 commit comments