Skip to content

Commit c208061

Browse files
Merge pull request #119 from browserstack/unit_tests_local_binary
removed local object creation
2 parents 17cde98 + 899ad87 commit c208061

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

test/unit/bin/helpers/utils.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ describe('utils', () => {
837837
});
838838

839839
describe('setupLocalTesting' ,() => {
840-
840+
841841
beforeEach(function () {
842842
sinon.restore();
843843
sandbox.restore();
@@ -985,12 +985,13 @@ describe('utils', () => {
985985
it('stopLocalBinary promise resolves with undefined if the bs_local isRunning is false' ,() => {
986986
let bsConfig = {
987987
connection_settings: {
988-
local_mode: true
988+
local_mode: "on-demand"
989989
}
990990
};
991-
let bs_local = new browserstack.Local();
992-
let isRunningStub = sinon.stub(bs_local,"isRunning");
993-
isRunningStub.returns(false);
991+
let isRunningStub = sandbox.stub().returns(false);
992+
let bs_local = {
993+
isRunning: isRunningStub,
994+
};
994995
return utils.stopLocalBinary(bsConfig, bs_local).then((result) => {
995996
expect(result).to.be.eq(undefined);
996997
});
@@ -1002,24 +1003,27 @@ describe('utils', () => {
10021003
local_mode: "always-on"
10031004
}
10041005
};
1005-
let bs_local = new browserstack.Local();
1006-
let isRunningStub = sinon.stub(bs_local,"isRunning");
1007-
isRunningStub.returns(true);
1006+
let isRunningStub = sandbox.stub().returns(true);
1007+
let bs_local = {
1008+
isRunning: isRunningStub,
1009+
}
10081010
return utils.stopLocalBinary(bsConfig, bs_local).then((result) => {
10091011
expect(result).to.be.eq(undefined);
10101012
});
10111013
});
1012-
1014+
10131015
it('if the bs_local isRunning is true and local_mode is not always-on and there is no stop error, then gets resolve with undefined' ,() => {
10141016
let bsConfig = {
10151017
connection_settings: {
10161018
local_mode: "on-demand"
10171019
}
10181020
};
1019-
let bs_local = new browserstack.Local();
1020-
let isRunningStub = sinon.stub(bs_local,"isRunning");
1021-
isRunningStub.returns(true);
1022-
sinon.stub(bs_local,"stop").yields(undefined);
1021+
let isRunningStub = sandbox.stub().returns(true);
1022+
let stopStub = sandbox.stub().yields(undefined);
1023+
let bs_local = {
1024+
isRunning: isRunningStub,
1025+
stop: stopStub
1026+
}
10231027
return utils.stopLocalBinary(bsConfig, bs_local).then((result) => {
10241028
expect(result).to.be.eq(undefined);
10251029
});
@@ -1031,11 +1035,13 @@ describe('utils', () => {
10311035
local_mode: "on-demand"
10321036
}
10331037
};
1034-
let bs_local = new browserstack.Local();
1035-
let isRunningStub = sinon.stub(bs_local,"isRunning");
1036-
isRunningStub.returns(true);
1038+
let isRunningStub = sandbox.stub().returns(true);
10371039
let error = new Error('Local Stop Error');
1038-
let stopStub = sinon.stub(bs_local,"stop").yields(error);
1040+
let stopStub = sandbox.stub().yields(error);
1041+
let bs_local = {
1042+
isRunning: isRunningStub,
1043+
stop: stopStub
1044+
}
10391045
let sendUsageReportStub = sandbox
10401046
.stub(utils, 'sendUsageReport')
10411047
.callsFake(function () {

0 commit comments

Comments
 (0)