@@ -1234,7 +1234,7 @@ describe('utils', () => {
1234
1234
sandbox . restore ( ) ;
1235
1235
} ) ;
1236
1236
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' , ( ) => {
1238
1238
let bsConfig = {
1239
1239
auth : {
1240
1240
access_key : 'xyz' ,
@@ -1245,11 +1245,11 @@ describe('utils', () => {
1245
1245
} ,
1246
1246
} ;
1247
1247
let args = { } ;
1248
- let checkLocalIdentifierRunningStub = sinon . stub (
1248
+ let checkLocalBinaryRunningStub = sinon . stub (
1249
1249
utils ,
1250
- 'checkLocalIdentifierRunning '
1250
+ 'checkLocalBinaryRunning '
1251
1251
) ;
1252
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( false ) ) ;
1252
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : true } ) ) ;
1253
1253
let setLocalArgsStub = sinon . stub ( utils , 'setLocalArgs' ) ;
1254
1254
setLocalArgsStub . returns ( { } ) ;
1255
1255
let localBinaryStartStub = sandbox
@@ -1270,7 +1270,7 @@ describe('utils', () => {
1270
1270
} ) ;
1271
1271
} ) ;
1272
1272
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' , ( ) => {
1274
1274
let bsConfig = {
1275
1275
auth : {
1276
1276
access_key : 'xyz' ,
@@ -1286,11 +1286,11 @@ describe('utils', () => {
1286
1286
localIdentifier : 'abc' ,
1287
1287
daemon : true ,
1288
1288
} ;
1289
- let checkLocalIdentifierRunningStub = sinon . stub (
1289
+ let checkLocalBinaryRunningStub = sinon . stub (
1290
1290
utils ,
1291
- 'checkLocalIdentifierRunning '
1291
+ 'checkLocalBinaryRunning '
1292
1292
) ;
1293
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( false ) ) ;
1293
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : true } ) ) ;
1294
1294
let setLocalArgsStub = sinon . stub ( utils , 'setLocalArgs' ) ;
1295
1295
setLocalArgsStub . returns ( localArgs ) ;
1296
1296
@@ -1322,11 +1322,11 @@ describe('utils', () => {
1322
1322
} ,
1323
1323
} ;
1324
1324
let args = { } ;
1325
- let checkLocalIdentifierRunningStub = sinon . stub (
1325
+ let checkLocalBinaryRunningStub = sinon . stub (
1326
1326
utils ,
1327
- 'checkLocalIdentifierRunning '
1327
+ 'checkLocalBinaryRunning '
1328
1328
) ;
1329
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1329
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
1330
1330
return utils . setupLocalTesting ( bsConfig , args ) . then ( ( result ) => {
1331
1331
expect ( result ) . to . be . eq ( undefined ) ;
1332
1332
} ) ;
@@ -1373,19 +1373,19 @@ describe('utils', () => {
1373
1373
local : true ,
1374
1374
} ,
1375
1375
} ;
1376
- let checkLocalIdentifierRunningStub = sinon . stub (
1376
+ let checkLocalBinaryRunningStub = sinon . stub (
1377
1377
utils ,
1378
- 'checkLocalIdentifierRunning '
1378
+ 'checkLocalBinaryRunning '
1379
1379
) ;
1380
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( false ) ) ;
1380
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : true } ) ) ;
1381
1381
let sendUsageReportStub = sandbox
1382
1382
. stub ( utils , 'sendUsageReport' )
1383
1383
. callsFake ( function ( ) {
1384
1384
return 'end' ;
1385
1385
} ) ;
1386
- return utils . stopLocalBinary ( bsConfig ) . then ( ( result ) => {
1386
+ return utils . stopLocalBinary ( bsConfig , null , null , null ) . then ( ( result ) => {
1387
1387
expect ( result ) . to . be . eq ( undefined ) ;
1388
- sinon . assert . calledOnce ( sendUsageReportStub ) ;
1388
+ sinon . assert . notCalled ( sendUsageReportStub ) ;
1389
1389
} ) ;
1390
1390
} ) ;
1391
1391
@@ -1399,11 +1399,11 @@ describe('utils', () => {
1399
1399
let bs_local = {
1400
1400
isRunning : isRunningStub ,
1401
1401
} ;
1402
- let checkLocalIdentifierRunningStub = sinon . stub (
1402
+ let checkLocalBinaryRunningStub = sinon . stub (
1403
1403
utils ,
1404
- 'checkLocalIdentifierRunning '
1404
+ 'checkLocalBinaryRunning '
1405
1405
) ;
1406
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1406
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
1407
1407
return utils . stopLocalBinary ( bsConfig , bs_local ) . then ( ( result ) => {
1408
1408
expect ( result ) . to . be . eq ( undefined ) ;
1409
1409
} ) ;
@@ -1419,11 +1419,11 @@ describe('utils', () => {
1419
1419
let bs_local = {
1420
1420
isRunning : isRunningStub ,
1421
1421
} ;
1422
- let checkLocalIdentifierRunningStub = sinon . stub (
1422
+ let checkLocalBinaryRunningStub = sinon . stub (
1423
1423
utils ,
1424
- 'checkLocalIdentifierRunning '
1424
+ 'checkLocalBinaryRunning '
1425
1425
) ;
1426
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1426
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
1427
1427
return utils . stopLocalBinary ( bsConfig , bs_local ) . then ( ( result ) => {
1428
1428
expect ( result ) . to . be . eq ( undefined ) ;
1429
1429
} ) ;
@@ -1441,11 +1441,11 @@ describe('utils', () => {
1441
1441
isRunning : isRunningStub ,
1442
1442
stop : stopStub ,
1443
1443
} ;
1444
- let checkLocalIdentifierRunningStub = sinon . stub (
1444
+ let checkLocalBinaryRunningStub = sinon . stub (
1445
1445
utils ,
1446
- 'checkLocalIdentifierRunning '
1446
+ 'checkLocalBinaryRunning '
1447
1447
) ;
1448
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1448
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
1449
1449
return utils . stopLocalBinary ( bsConfig , bs_local ) . then ( ( result ) => {
1450
1450
expect ( result ) . to . be . eq ( undefined ) ;
1451
1451
} ) ;
@@ -1460,11 +1460,11 @@ describe('utils', () => {
1460
1460
let isRunningStub = sandbox . stub ( ) . returns ( true ) ;
1461
1461
let error = new Error ( 'Local Stop Error' ) ;
1462
1462
let stopStub = sandbox . stub ( ) . yields ( error ) ;
1463
- let checkLocalIdentifierRunningStub = sinon . stub (
1463
+ let checkLocalBinaryRunningStub = sinon . stub (
1464
1464
utils ,
1465
- 'checkLocalIdentifierRunning '
1465
+ 'checkLocalBinaryRunning '
1466
1466
) ;
1467
- checkLocalIdentifierRunningStub . returns ( Promise . resolve ( true ) ) ;
1467
+ checkLocalBinaryRunningStub . returns ( Promise . resolve ( { "should_spawn_binary" : false } ) ) ;
1468
1468
let bs_local = {
1469
1469
isRunning : isRunningStub ,
1470
1470
stop : stopStub ,
@@ -1503,7 +1503,7 @@ describe('utils', () => {
1503
1503
afterEach ( function ( ) {
1504
1504
delete process . env . BROWSERSTACK_LOCAL_IDENTIFIER ;
1505
1505
} ) ;
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' , ( ) => {
1507
1507
let bsConfig = {
1508
1508
connection_settings : {
1509
1509
local : true ,
@@ -1516,7 +1516,8 @@ describe('utils', () => {
1516
1516
) ;
1517
1517
generateLocalIdentifierStub . returns ( 'abc' ) ;
1518
1518
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 ) ;
1520
1521
} ) ;
1521
1522
1522
1523
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', () => {
2392
2393
} ) ;
2393
2394
} ) ;
2394
2395
2395
- describe ( '#checkLocalIdentifierRunning ' , ( ) => {
2396
+ describe ( '#checkLocalBinaryRunning ' , ( ) => {
2396
2397
afterEach ( ( ) => {
2397
2398
sinon . restore ( ) ;
2398
2399
} ) ;
@@ -2404,21 +2405,10 @@ describe('utils', () => {
2404
2405
} ,
2405
2406
} ;
2406
2407
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
2419
2409
} ;
2420
2410
sinon
2421
- . stub ( request , 'get ' )
2411
+ . stub ( request , 'post ' )
2422
2412
. yields ( undefined , responseObject , JSON . stringify ( responseBody ) ) ;
2423
2413
2424
2414
let bsConfig = {
@@ -2430,35 +2420,22 @@ describe('utils', () => {
2430
2420
2431
2421
let localIdentifier = 'abcd' ;
2432
2422
return utils
2433
- . checkLocalIdentifierRunning ( bsConfig , localIdentifier )
2423
+ . checkLocalBinaryRunning ( bsConfig , localIdentifier )
2434
2424
. then ( ( result ) => {
2435
- expect ( result ) . to . be . eq ( false ) ;
2425
+ chai . assert . deepEqual ( result , { "should_spawn_binary" : true } ) ;
2436
2426
} ) ;
2437
2427
} ) ;
2438
2428
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' , ( ) => {
2440
2430
const responseObject = {
2441
2431
statusCode : 200 ,
2442
2432
headers : {
2443
2433
'content-type' : 'application/json' ,
2444
2434
} ,
2445
2435
} ;
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 } ;
2460
2437
sinon
2461
- . stub ( request , 'get ' )
2438
+ . stub ( request , 'post ' )
2462
2439
. yields ( undefined , responseObject , JSON . stringify ( responseBody ) ) ;
2463
2440
2464
2441
let bsConfig = {
@@ -2470,9 +2447,9 @@ describe('utils', () => {
2470
2447
2471
2448
let localIdentifier = 'lmno' ;
2472
2449
return utils
2473
- . checkLocalIdentifierRunning ( bsConfig , localIdentifier )
2450
+ . checkLocalBinaryRunning ( bsConfig , localIdentifier )
2474
2451
. then ( ( result ) => {
2475
- expect ( result ) . to . be . eq ( true ) ;
2452
+ chai . assert . deepEqual ( result , { "should_spawn_binary" : false } )
2476
2453
} ) ;
2477
2454
} ) ;
2478
2455
} ) ;
0 commit comments