Skip to content

Commit 716bb15

Browse files
Roshan NikamRoshan Nikam
authored andcommitted
added specs for the changes
1 parent f438c85 commit 716bb15

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

test/unit/bin/commands/runs.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ describe("runs", () => {
206206

207207
beforeEach(() => {
208208
sandbox = sinon.createSandbox();
209+
getParallelsStub = sandbox.stub();
209210
setParallelsStub = sandbox.stub();
210211
warnSpecLimitStub = sandbox.stub();
211212
setUsernameStub = sandbox.stub();
@@ -257,6 +258,7 @@ describe("runs", () => {
257258
'../helpers/utils': {
258259
validateBstackJson: validateBstackJsonStub,
259260
sendUsageReport: sendUsageReportStub,
261+
getParallels: getParallelsStub,
260262
setParallels: setParallelsStub,
261263
warnSpecLimit: warnSpecLimitStub,
262264
setUsername: setUsernameStub,
@@ -322,6 +324,7 @@ describe("runs", () => {
322324
sinon.assert.calledOnce(setLocalConfigFileStub);
323325
sinon.assert.calledOnce(setCypressConfigFilenameStub);
324326
sinon.assert.calledOnce(getNumberOfSpecFilesStub);
327+
sinon.assert.calledOnce(getParallelsStub);
325328
sinon.assert.calledOnce(setParallelsStub);
326329
sinon.assert.calledOnce(warnSpecLimitStub);
327330
sinon.assert.calledOnce(setLocalStub);
@@ -356,6 +359,7 @@ describe("runs", () => {
356359
beforeEach(() => {
357360
sandbox = sinon.createSandbox();
358361
validateBstackJsonStub = sandbox.stub();
362+
getParallelsStub = sandbox.stub();
359363
setParallelsStub = sandbox.stub();
360364
warnSpecLimitStub = sandbox.stub();
361365
setUsernameStub = sandbox.stub();
@@ -407,6 +411,7 @@ describe("runs", () => {
407411
'../helpers/utils': {
408412
validateBstackJson: validateBstackJsonStub,
409413
sendUsageReport: sendUsageReportStub,
414+
getParallels: getParallelsStub,
410415
setParallels: setParallelsStub,
411416
warnSpecLimit: warnSpecLimitStub,
412417
setUsername: setUsernameStub,
@@ -472,6 +477,7 @@ describe("runs", () => {
472477
sinon.assert.calledOnce(setLocalModeStub);
473478
sinon.assert.calledOnce(setLocalConfigFileStub);
474479
sinon.assert.calledOnce(getNumberOfSpecFilesStub);
480+
sinon.assert.calledOnce(getParallelsStub);
475481
sinon.assert.calledOnce(setParallelsStub);
476482
sinon.assert.calledOnce(warnSpecLimitStub);
477483
sinon.assert.calledOnce(setLocalStub);
@@ -509,6 +515,7 @@ describe("runs", () => {
509515
beforeEach(() => {
510516
sandbox = sinon.createSandbox();
511517
validateBstackJsonStub = sandbox.stub();
518+
getParallelsStub = sandbox.stub();
512519
setParallelsStub = sandbox.stub();
513520
warnSpecLimitStub = sandbox.stub();
514521
setUsernameStub = sandbox.stub();
@@ -562,6 +569,7 @@ describe("runs", () => {
562569
'../helpers/utils': {
563570
validateBstackJson: validateBstackJsonStub,
564571
sendUsageReport: sendUsageReportStub,
572+
getParallels: getParallelsStub,
565573
setParallels: setParallelsStub,
566574
warnSpecLimit: warnSpecLimitStub,
567575
setUsername: setUsernameStub,
@@ -638,6 +646,7 @@ describe("runs", () => {
638646
sinon.assert.calledOnce(validateBstackJsonStub);
639647
sinon.assert.calledOnce(capabilityValidatorStub);
640648
sinon.assert.calledOnce(getNumberOfSpecFilesStub);
649+
sinon.assert.calledOnce(getParallelsStub);
641650
sinon.assert.calledOnce(setParallelsStub);
642651
sinon.assert.calledOnce(warnSpecLimitStub);
643652
sinon.assert.calledOnce(setLocalStub);
@@ -675,6 +684,7 @@ describe("runs", () => {
675684
beforeEach(() => {
676685
sandbox = sinon.createSandbox();
677686
validateBstackJsonStub = sandbox.stub();
687+
getParallelsStub = sandbox.stub();
678688
setParallelsStub = sandbox.stub();
679689
warnSpecLimitStub = sandbox.stub()
680690
setUsernameStub = sandbox.stub();
@@ -736,7 +746,7 @@ describe("runs", () => {
736746
let errorCode = null;
737747
let message = `Success! ${Constants.userMessages.BUILD_CREATED} with build id: random_build_id`;
738748
let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${dashboardUrl}`;
739-
let data = {time_components: {}, unique_id: 'random_hash', package_error: 'test', checkmd5_error: 'test', build_id: 'random_build_id'}
749+
let data = { user_id: 1234, parallels: 10, time_components: {}, unique_id: 'random_hash', package_error: 'test', checkmd5_error: 'test', build_id: 'random_build_id'}
740750

741751
const runs = proxyquire('../../../../bin/commands/runs', {
742752
'../helpers/utils': {
@@ -750,6 +760,7 @@ describe("runs", () => {
750760
setTestEnvs: setTestEnvsStub,
751761
setSystemEnvs: setSystemEnvsStub,
752762
setUsageReportingFlag: setUsageReportingFlagStub,
763+
getParallels: getParallelsStub,
753764
setParallels: setParallelsStub,
754765
warnSpecLimit: warnSpecLimitStub,
755766
getConfigPath: getConfigPathStub,
@@ -821,7 +832,8 @@ describe("runs", () => {
821832
stopLocalBinaryStub.returns(Promise.resolve("nothing"));
822833
nonEmptyArrayStub.returns(false);
823834
checkErrorStub.returns('test');
824-
createBuildStub.returns(Promise.resolve({ message: 'Success', build_id: 'random_build_id', dashboard_url: dashboardUrl }));
835+
getParallelsStub.returns(10);
836+
createBuildStub.returns(Promise.resolve({ message: 'Success', build_id: 'random_build_id', dashboard_url: dashboardUrl, user_id: 1234 }));
825837

826838
return runs(args)
827839
.then(function (_bsConfig) {
@@ -834,6 +846,7 @@ describe("runs", () => {
834846
sinon.assert.calledOnce(setLocalConfigFileStub);
835847
sinon.assert.calledOnce(capabilityValidatorStub);
836848
sinon.assert.calledOnce(getNumberOfSpecFilesStub);
849+
sinon.assert.calledOnce(getParallelsStub);
837850
sinon.assert.calledOnce(setParallelsStub);
838851
sinon.assert.calledOnce(warnSpecLimitStub);
839852
sinon.assert.calledOnce(setLocalStub);

test/unit/bin/helpers/utils.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,38 @@ describe('utils', () => {
239239
});
240240
});
241241

242+
describe('getparallels', () =>{
243+
it('should return the parallels specified by the user as arguments', ()=>{
244+
let bsConfig = {
245+
run_settings: {
246+
parallels: 100,
247+
},
248+
};
249+
let args = {
250+
parallels: 200
251+
};
252+
expect(utils.getParallels(bsConfig, args)).to.be.eq(200);
253+
});
254+
255+
it('should return the parallels specified by the user in bsconfig if not passed as arguments', ()=>{
256+
let bsConfig = {
257+
run_settings: {
258+
parallels: 100,
259+
},
260+
};
261+
let args = {};
262+
expect(utils.getParallels(bsConfig, args)).to.be.eq(100);
263+
});
264+
265+
it('should return the undefined if no parallels specified in bsconfig and arguments', ()=>{
266+
let bsConfig = {
267+
run_settings: {},
268+
};
269+
let args = {};
270+
expect(utils.getParallels(bsConfig, args)).to.be.eq(undefined);
271+
});
272+
});
273+
242274
describe('checkError', () => {
243275
it('should return error if exists', () => {
244276
expect(utils.checkError({error: "test error"})).to.be.eq("test error");

0 commit comments

Comments
 (0)