Skip to content

Commit 00140a9

Browse files
committed
added rspecs
1 parent f69335e commit 00140a9

File tree

2 files changed

+68
-3
lines changed

2 files changed

+68
-3
lines changed

test/unit/bin/commands/runs.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ describe("runs", () => {
122122
setSpecTimeoutStub = sandbox.stub().returns(undefined);
123123
setRecordCapsStub = sandbox.stub().returns(undefined);
124124
setNodeVersionStub = sandbox.stub();
125+
setBuildTagsStub = sandbox.stub();
125126
});
126127

127128
afterEach(() => {
@@ -166,7 +167,8 @@ describe("runs", () => {
166167
setSpecTimeout: setSpecTimeoutStub,
167168
setRecordCaps: setRecordCapsStub,
168169
setDebugMode: setDebugModeStub,
169-
setNodeVersion: setNodeVersionStub
170+
setNodeVersion: setNodeVersionStub,
171+
setBuildTags: setBuildTagsStub
170172
},
171173
'../helpers/capabilityHelper': {
172174
validate: capabilityValidatorStub
@@ -215,6 +217,7 @@ describe("runs", () => {
215217
sinon.assert.calledOnce(getInitialDetailsStub);
216218
sinon.assert.calledOnce(setRecordCapsStub);
217219
sinon.assert.calledOnce(setNodeVersionStub);
220+
sinon.assert.calledOnce(setBuildTagsStub);
218221
sinon.assert.calledOnceWithExactly(
219222
sendUsageReportStub,
220223
bsConfig,
@@ -276,6 +279,7 @@ describe("runs", () => {
276279
setSpecTimeoutStub = sandbox.stub().returns(undefined);
277280
setRecordCapsStub = sandbox.stub().returns(undefined);
278281
setNodeVersionStub = sandbox.stub();
282+
setBuildTagsStub = sandbox.stub();
279283
});
280284

281285
afterEach(() => {
@@ -323,7 +327,8 @@ describe("runs", () => {
323327
setSpecTimeout: setSpecTimeoutStub,
324328
setRecordCaps: setRecordCapsStub,
325329
setDebugMode: setDebugModeStub,
326-
setNodeVersion: setNodeVersionStub
330+
setNodeVersion: setNodeVersionStub,
331+
setBuildTags: setBuildTagsStub
327332
},
328333
'../helpers/capabilityHelper': {
329334
validate: capabilityValidatorStub,
@@ -391,6 +396,7 @@ describe("runs", () => {
391396
sinon.assert.calledOnce(getInitialDetailsStub);
392397
sinon.assert.calledOnce(setRecordCapsStub);
393398
sinon.assert.calledOnce(setNodeVersionStub);
399+
sinon.assert.calledOnce(setBuildTagsStub);
394400
sinon.assert.calledOnceWithExactly(
395401
sendUsageReportStub,
396402
bsConfig,
@@ -454,6 +460,7 @@ describe("runs", () => {
454460
getInitialDetailsStub = sandbox.stub();
455461
setRecordCapsStub = sandbox.stub().returns(undefined);
456462
setNodeVersionStub = sandbox.stub();
463+
setBuildTagsStub = sandbox.stub();
457464
});
458465

459466
afterEach(() => {
@@ -502,7 +509,8 @@ describe("runs", () => {
502509
setSpecTimeout: setSpecTimeoutStub,
503510
setRecordCaps: setRecordCapsStub,
504511
setDebugMode: setDebugModeStub,
505-
setNodeVersion: setNodeVersionStub
512+
setNodeVersion: setNodeVersionStub,
513+
setBuildTags: setBuildTagsStub
506514
},
507515
'../helpers/capabilityHelper': {
508516
validate: capabilityValidatorStub,
@@ -572,6 +580,7 @@ describe("runs", () => {
572580
sinon.assert.calledOnce(getInitialDetailsStub);
573581
sinon.assert.calledOnce(setRecordCapsStub);
574582
sinon.assert.calledOnce(setNodeVersionStub);
583+
sinon.assert.calledOnce(setBuildTagsStub);
575584
sinon.assert.calledOnceWithExactly(
576585
sendUsageReportStub,
577586
bsConfig,
@@ -640,6 +649,7 @@ describe("runs", () => {
640649
getInitialDetailsStub = sandbox.stub();
641650
setRecordCapsStub = sandbox.stub().returns(undefined);
642651
setNodeVersionStub = sandbox.stub();
652+
setBuildTagsStub = sandbox.stub();
643653
});
644654

645655
afterEach(() => {
@@ -690,6 +700,7 @@ describe("runs", () => {
690700
setRecordCaps: setRecordCapsStub,
691701
setDebugMode: setDebugModeStub,
692702
setNodeVersion: setNodeVersionStub,
703+
setBuildTags: setBuildTagsStub
693704
},
694705
'../helpers/capabilityHelper': {
695706
validate: capabilityValidatorStub,
@@ -770,6 +781,7 @@ describe("runs", () => {
770781
sinon.assert.calledOnce(getInitialDetailsStub);
771782
sinon.assert.calledOnce(setRecordCapsStub);
772783
sinon.assert.calledOnce(setNodeVersionStub);
784+
sinon.assert.calledOnce(setBuildTagsStub);
773785

774786
sinon.assert.calledOnceWithExactly(
775787
sendUsageReportStub,
@@ -852,6 +864,7 @@ describe("runs", () => {
852864
getInitialDetailsStub = sandbox.stub();
853865
setRecordCapsStub = sandbox.stub().returns(undefined);
854866
setNodeVersionStub = sandbox.stub();
867+
setBuildTagsStub = sandbox.stub();
855868
});
856869

857870
afterEach(() => {
@@ -910,6 +923,7 @@ describe("runs", () => {
910923
setRecordCaps: setRecordCapsStub,
911924
setDebugMode: setDebugModeStub,
912925
setNodeVersion: setNodeVersionStub,
926+
setBuildTags: setBuildTagsStub
913927
},
914928
'../helpers/capabilityHelper': {
915929
validate: capabilityValidatorStub,
@@ -1006,6 +1020,7 @@ describe("runs", () => {
10061020
sinon.assert.calledOnce(getInitialDetailsStub);
10071021
sinon.assert.calledOnce(setRecordCapsStub);
10081022
sinon.assert.calledOnce(setNodeVersionStub);
1023+
sinon.assert.calledOnce(setBuildTagsStub);
10091024
sinon.assert.match(
10101025
sendUsageReportStub.getCall(0).args,
10111026
[

test/unit/bin/helpers/utils.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,4 +3378,54 @@ describe('utils', () => {
33783378
expect(utils.formatRequest(null, {statusCode: 500}, cricularBody)).to.be.eql({err: null, status: 500, body: '[Circular]'});
33793379
});
33803380
});
3381+
3382+
describe('setBuildTags', () => {
3383+
it('should give preference to args', () => {
3384+
let bsConfig = {
3385+
run_settings: {
3386+
build_tag: "abc"
3387+
}
3388+
}
3389+
3390+
let args = {
3391+
"build-tag": "def"
3392+
}
3393+
utils.setBuildTags(bsConfig, args);
3394+
expect(bsConfig.run_settings.build_tag).to.be.eq("def");
3395+
});
3396+
});
3397+
3398+
it('should honour bstack json if args not passed', () => {
3399+
let bsConfig = {
3400+
run_settings: {
3401+
build_tag: "abc"
3402+
}
3403+
}
3404+
3405+
let args = {}
3406+
utils.setBuildTags(bsConfig, args);
3407+
expect(bsConfig.run_settings.build_tag).to.be.eq("abc");
3408+
});
3409+
3410+
it('should convert values to string', () => {
3411+
let bsConfig = {
3412+
run_settings: {
3413+
build_tag: 1234
3414+
}
3415+
}
3416+
3417+
let args = {}
3418+
utils.setBuildTags(bsConfig, args);
3419+
expect(bsConfig.run_settings.build_tag).to.be.eq("1234");
3420+
});
3421+
3422+
it('should set undefined if args and bstack json caps not passed', () => {
3423+
let bsConfig = {
3424+
run_settings: {}
3425+
}
3426+
3427+
let args = {}
3428+
utils.setBuildTags(bsConfig, args);
3429+
expect(bsConfig.run_settings.build_tag).to.be.eq(undefined);
3430+
});
33813431
});

0 commit comments

Comments
 (0)