Skip to content

Commit abce52e

Browse files
committed
added specs for the changes
1 parent c9317b5 commit abce52e

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

test/unit/bin/commands/runs.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ describe("runs", () => {
116116
setConfigStub = sandbox.stub();
117117
setCLIModeStub = sandbox.stub();
118118
setGeolocationStub = sandbox.stub();
119+
setSpecTimeoutStub = sandbox.stub().returns(undefined);
119120
});
120121

121122
afterEach(() => {
@@ -156,7 +157,8 @@ describe("runs", () => {
156157
setBrowsers: setBrowsersStub,
157158
setConfig: setConfigStub,
158159
setCLIMode: setCLIModeStub,
159-
setGeolocation: setGeolocationStub
160+
setGeolocation: setGeolocationStub,
161+
setSpecTimeout: setSpecTimeoutStub
160162
},
161163
'../helpers/capabilityHelper': {
162164
validate: capabilityValidatorStub
@@ -197,6 +199,7 @@ describe("runs", () => {
197199
sinon.assert.calledOnce(setLocalIdentifierStub);
198200
sinon.assert.calledOnce(setUsageReportingFlagStub);
199201
sinon.assert.calledOnce(setGeolocationStub);
202+
sinon.assert.calledOnce(setSpecTimeoutStub);
200203
sinon.assert.calledOnceWithExactly(
201204
sendUsageReportStub,
202205
bsConfig,
@@ -254,6 +257,7 @@ describe("runs", () => {
254257
setCLIModeStub = sandbox.stub();
255258
setGeolocationStub = sandbox.stub();
256259
getVideoConfigStub = sandbox.stub();
260+
setSpecTimeoutStub = sandbox.stub().returns(undefined);
257261
});
258262

259263
afterEach(() => {
@@ -298,6 +302,7 @@ describe("runs", () => {
298302
setCLIMode: setCLIModeStub,
299303
setGeolocation: setGeolocationStub,
300304
getVideoConfig: getVideoConfigStub,
305+
setSpecTimeout: setSpecTimeoutStub
301306
},
302307
'../helpers/capabilityHelper': {
303308
validate: capabilityValidatorStub,
@@ -357,6 +362,7 @@ describe("runs", () => {
357362
sinon.assert.calledOnce(setDefaultsStub);
358363
sinon.assert.calledOnce(setSystemEnvsStub);
359364
sinon.assert.calledOnce(setGeolocationStub);
365+
sinon.assert.calledOnce(setSpecTimeoutStub);
360366
sinon.assert.calledOnceWithExactly(
361367
sendUsageReportStub,
362368
bsConfig,
@@ -416,6 +422,7 @@ describe("runs", () => {
416422
fetchZipSizeStub = sandbox.stub();
417423
setGeolocationStub = sandbox.stub();
418424
getVideoConfigStub = sandbox.stub();
425+
setSpecTimeoutStub = sandbox.stub().returns(undefined);
419426
});
420427

421428
afterEach(() => {
@@ -461,6 +468,7 @@ describe("runs", () => {
461468
fetchZipSize: fetchZipSizeStub,
462469
setGeolocation: setGeolocationStub,
463470
getVideoConfig: getVideoConfigStub,
471+
setSpecTimeout: setSpecTimeoutStub
464472
},
465473
'../helpers/capabilityHelper': {
466474
validate: capabilityValidatorStub,
@@ -522,6 +530,7 @@ describe("runs", () => {
522530
sinon.assert.calledOnce(setDefaultsStub);
523531
sinon.assert.calledOnce(setSystemEnvsStub);
524532
sinon.assert.calledOnce(setGeolocationStub);
533+
sinon.assert.calledOnce(setSpecTimeoutStub);
525534
sinon.assert.calledOnceWithExactly(
526535
sendUsageReportStub,
527536
bsConfig,
@@ -586,6 +595,7 @@ describe("runs", () => {
586595
fetchZipSizeStub = sandbox.stub();
587596
setGeolocationStub = sandbox.stub();
588597
getVideoConfigStub = sandbox.stub();
598+
setSpecTimeoutStub = sandbox.stub().returns(undefined);
589599
});
590600

591601
afterEach(() => {
@@ -632,6 +642,7 @@ describe("runs", () => {
632642
fetchZipSize: fetchZipSizeStub,
633643
setGeolocation: setGeolocationStub,
634644
getVideoConfig: getVideoConfigStub,
645+
setSpecTimeout: setSpecTimeoutStub
635646
},
636647
'../helpers/capabilityHelper': {
637648
validate: capabilityValidatorStub,
@@ -704,6 +715,7 @@ describe("runs", () => {
704715
sinon.assert.calledOnce(setDefaultsStub);
705716
sinon.assert.calledOnce(setSystemEnvsStub);
706717
sinon.assert.calledOnce(setGeolocationStub);
718+
sinon.assert.calledOnce(setSpecTimeoutStub);
707719

708720
sinon.assert.calledOnceWithExactly(
709721
sendUsageReportStub,
@@ -782,6 +794,7 @@ describe("runs", () => {
782794
fetchZipSizeStub = sandbox.stub();
783795
setGeolocationStub = sandbox.stub();
784796
getVideoConfigStub = sandbox.stub();
797+
setSpecTimeoutStub = sandbox.stub().returns(undefined);
785798
});
786799

787800
afterEach(() => {
@@ -836,6 +849,7 @@ describe("runs", () => {
836849
fetchZipSize: fetchZipSizeStub,
837850
setGeolocation: setGeolocationStub,
838851
getVideoConfig: getVideoConfigStub,
852+
setSpecTimeout: setSpecTimeoutStub
839853
},
840854
'../helpers/capabilityHelper': {
841855
validate: capabilityValidatorStub,

test/unit/bin/helpers/utils.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,7 @@ describe('utils', () => {
13581358
expect(local_args['daemon']).to.be.eq(true);
13591359
expect(local_args['enable-logging-for-api']).to.be.eq(true);
13601360
expect(local_args['config-file']).to.be.eq(path.resolve('./local.yml'));
1361+
cliVersionPathStub.restore();
13611362
sinon.restore();
13621363
});
13631364
});
@@ -2942,4 +2943,89 @@ describe('utils', () => {
29422943
expect(utils.getVideoConfig({video: false, videoUploadOnPasses: false})).to.be.eql({video: false, videoUploadOnPasses: false});
29432944
});
29442945
});
2946+
2947+
describe('isSpecTimeoutArgPassed', () => {
2948+
let searchForOptionStub;
2949+
beforeEach(() => {
2950+
searchForOptionStub = sinon.stub(utils, 'searchForOption').withArgs('--spec-timeout');
2951+
})
2952+
afterEach(() => {
2953+
sinon.restore();
2954+
})
2955+
it('returns true if --spec-timeout flag is passed', () => {
2956+
searchForOptionStub.withArgs('--spec-timeout').returns(true);
2957+
expect(utils.isSpecTimeoutArgPassed()).to.eq(true);
2958+
});
2959+
2960+
it('returns true if -t flag is passed', () => {
2961+
searchForOptionStub.withArgs('--spec-timeout').returns(true);
2962+
searchForOptionStub.withArgs('-t').returns(true);
2963+
// stub2.returns(true);
2964+
expect(utils.isSpecTimeoutArgPassed()).to.eq(true);
2965+
});
2966+
2967+
it('returns false if no flag is passed', () => {
2968+
searchForOptionStub.withArgs('--spec-timeout').returns(false);
2969+
searchForOptionStub.withArgs('-t').returns(false);
2970+
expect(utils.isSpecTimeoutArgPassed()).to.eq(false);
2971+
});
2972+
});
2973+
2974+
describe("setSpecTimeout", () => {
2975+
let isSpecTimeoutArgPassedStub;
2976+
beforeEach(() => {
2977+
isSpecTimeoutArgPassedStub = sinon.stub(utils, 'isSpecTimeoutArgPassed');
2978+
});
2979+
2980+
afterEach(() => {
2981+
isSpecTimeoutArgPassedStub.restore();
2982+
});
2983+
it('sets spec_timeout defined value passed in args', () => {
2984+
let bsConfig = {
2985+
run_settings: {
2986+
spec_timeout: "abc"
2987+
}
2988+
}
2989+
let args = {
2990+
specTimeout: 20
2991+
};
2992+
isSpecTimeoutArgPassedStub.returns(true);
2993+
utils.setSpecTimeout(bsConfig, args);
2994+
expect(bsConfig.run_settings.spec_timeout).to.eq(20);
2995+
});
2996+
2997+
it('sets spec_timeout undefined if no value passed in args', () => {
2998+
let bsConfig = {
2999+
run_settings: {
3000+
spec_timeout: "abc"
3001+
}
3002+
}
3003+
let args = {};
3004+
isSpecTimeoutArgPassedStub.returns(true);
3005+
utils.setSpecTimeout(bsConfig, args);
3006+
expect(bsConfig.run_settings.spec_timeout).to.eq('undefined');
3007+
});
3008+
3009+
it('sets spec_timeout to value passed in bsConfig is not in args', () => {
3010+
let bsConfig = {
3011+
run_settings: {
3012+
spec_timeout: 20
3013+
}
3014+
}
3015+
let args = {};
3016+
isSpecTimeoutArgPassedStub.returns(false);
3017+
utils.setSpecTimeout(bsConfig, args);
3018+
expect(bsConfig.run_settings.spec_timeout).to.eq(20);
3019+
});
3020+
3021+
it('sets spec_timeout to null if no value passed in args or bsConfig', () => {
3022+
let bsConfig = {
3023+
run_settings: {}
3024+
}
3025+
let args = {};
3026+
isSpecTimeoutArgPassedStub.returns(false);
3027+
utils.setSpecTimeout(bsConfig, args);
3028+
expect(bsConfig.run_settings.spec_timeout).to.eq(null);
3029+
});
3030+
});
29453031
});

0 commit comments

Comments
 (0)