Skip to content

Commit 976971f

Browse files
Roshan NikamRoshan Nikam
authored andcommitted
added spec for covering code changes
1 parent d82a870 commit 976971f

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

test/unit/bin/helpers/reporterHTML.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe("reportHTML", () => {
2121
var sandbox;
2222
let templateDir = 'templateDir',
2323
args = testObjects.generateReportInputArgs,
24+
rawArgs = testObjects.generateReportInputRawArgs
2425
buildId = 'buildId',
2526
bsConfig = testObjects.sampleBsConfig;
2627

@@ -40,7 +41,6 @@ describe("reportHTML", () => {
4041
reportGeneratorSpy = sandbox.spy();
4142
getErrorCodeFromErrStub = sandbox.stub().returns("random-error");
4243
setDefaultsStub = sandbox.stub();
43-
4444
getUserAgentStub = sandbox.stub().returns("random user-agent");
4545
// pathStub = sinon.stub(path, 'join').returns(templateDir);
4646
});
@@ -75,11 +75,11 @@ describe("reportHTML", () => {
7575
request: {get: requestStub}
7676
});
7777

78-
reporterHTML.reportGenerator(bsConfig, buildId, args);
78+
reporterHTML.reportGenerator(bsConfig, buildId, args, rawArgs);
7979

8080
sinon.assert.calledOnce(requestStub);
8181
sinon.assert.calledOnce(getUserAgentStub);
82-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
82+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
8383
});
8484

8585
it("is deprecated, i.e. 299", () => {
@@ -106,11 +106,11 @@ describe("reportHTML", () => {
106106
request: {get: requestStub}
107107
});
108108

109-
reporterHTML.reportGenerator(bsConfig, buildId, args);
109+
reporterHTML.reportGenerator(bsConfig, buildId, args, rawArgs);
110110

111111
sinon.assert.calledOnce(requestStub);
112112
sinon.assert.calledOnce(getUserAgentStub);
113-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
113+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
114114
});
115115

116116
context("non 200 response", () => {
@@ -138,11 +138,11 @@ describe("reportHTML", () => {
138138
request: {get: requestStub}
139139
});
140140

141-
reporterHTML.reportGenerator(bsConfig, buildId, args);
141+
reporterHTML.reportGenerator(bsConfig, buildId, args, rawArgs);
142142

143143
sinon.assert.calledOnce(requestStub);
144144
sinon.assert.calledOnce(getUserAgentStub);
145-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
145+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
146146
});
147147

148148
it("400 status, build available, cannot generate report", () => {
@@ -171,11 +171,11 @@ describe("reportHTML", () => {
171171
request: {get: requestStub}
172172
});
173173

174-
reporterHTML.reportGenerator(bsConfig, buildId, args);
174+
reporterHTML.reportGenerator(bsConfig, buildId, args, rawArgs);
175175

176176
sinon.assert.calledOnce(requestStub);
177177
sinon.assert.calledOnce(getUserAgentStub);
178-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
178+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
179179
});
180180

181181
it("user is unauthorized", () => {
@@ -204,11 +204,11 @@ describe("reportHTML", () => {
204204
request: {get: requestStub}
205205
});
206206

207-
reporterHTML.reportGenerator(bsConfig, buildId, args);
207+
reporterHTML.reportGenerator(bsConfig, buildId, args, rawArgs);
208208

209209
sinon.assert.calledOnce(requestStub);
210210
sinon.assert.calledOnce(getUserAgentStub);
211-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
211+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
212212
});
213213

214214
it("400 status, build not available, cannot generate report", () => {
@@ -233,11 +233,11 @@ describe("reportHTML", () => {
233233
request: {get: requestStub}
234234
});
235235

236-
reporterHTML.reportGenerator(bsConfig, buildId, args);
236+
reporterHTML.reportGenerator(bsConfig, buildId, args, rawArgs);
237237

238238
sinon.assert.calledOnce(requestStub);
239239
sinon.assert.calledOnce(getUserAgentStub);
240-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
240+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
241241
});
242242
});
243243

@@ -265,11 +265,11 @@ describe("reportHTML", () => {
265265
request: {get: requestStub}
266266
});
267267

268-
reporterHTML.reportGenerator(bsConfig, buildId, args);
268+
reporterHTML.reportGenerator(bsConfig, buildId, args, rawArgs);
269269

270270
sinon.assert.calledOnce(requestStub);
271271
sinon.assert.calledOnce(getUserAgentStub);
272-
sendUsageReportStub.calledOnceWithExactly(bsConfig, args, message, messageType, errorCode);
272+
sendUsageReportStub.calledOnceWithExactly(bsConfig, args, message, messageType, errorCode, null, rawArgs);
273273
});
274274
});
275275

test/unit/bin/helpers/utils.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,7 +2557,8 @@ describe('utils', () => {
25572557
describe('stopBrowserStackBuild', () => {
25582558
let axiosPostStub, getUserAgentStub, sendUsageReportStub, message, messageType, errorCode;
25592559
let bsConfig = testObjects.sampleBsConfig;
2560-
let args = {}
2560+
let args = {};
2561+
let rawArgs = {};
25612562
let buildId = 'build_id';
25622563
let body = testObjects.buildStopSampleBody;
25632564

@@ -2581,10 +2582,10 @@ describe('utils', () => {
25812582
messageType = constant.messageTypes.INFO;
25822583
errorCode = 'api_deprecated';
25832584
axiosPostStub.resolves(api_deprecated_response);
2584-
await utils.stopBrowserStackBuild(bsConfig, args, buildId);
2585+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
25852586
sinon.assert.calledOnce(axiosPostStub);
25862587
sinon.assert.calledOnce(getUserAgentStub);
2587-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
2588+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
25882589
});
25892590

25902591
it('message thrown if build returned', async () => {
@@ -2596,10 +2597,10 @@ describe('utils', () => {
25962597
messageType = constant.messageTypes.INFO;
25972598
errorCode = 'api_deprecated';
25982599
axiosPostStub.resolves(api_deprecated_response);
2599-
await utils.stopBrowserStackBuild(bsConfig, args, buildId);
2600+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
26002601
sinon.assert.calledOnce(axiosPostStub);
26012602
sinon.assert.calledOnce(getUserAgentStub);
2602-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
2603+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
26032604
});
26042605

26052606
it('message thrown if statusCode != 200', async () => {
@@ -2610,10 +2611,10 @@ describe('utils', () => {
26102611
messageType = constant.messageTypes.ERROR;
26112612
errorCode = 'api_failed_build_stop';
26122613
axiosPostStub.resolves(non_200_status_response);
2613-
await utils.stopBrowserStackBuild(bsConfig, args, buildId);
2614+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
26142615
sinon.assert.calledOnce(axiosPostStub);
26152616
sinon.assert.calledOnce(getUserAgentStub);
2616-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
2617+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
26172618
});
26182619

26192620
it('message thrown if statusCode != 200 and user unauthorized', async () => {
@@ -2632,10 +2633,10 @@ describe('utils', () => {
26322633
messageType = constant.messageTypes.ERROR;
26332634
errorCode = 'api_auth_failed';
26342635
axiosPostStub.resolves(non_200_status_response);
2635-
await utils.stopBrowserStackBuild(bsConfig, args, buildId);
2636+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
26362637
sinon.assert.calledOnce(axiosPostStub);
26372638
sinon.assert.calledOnce(getUserAgentStub);
2638-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
2639+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
26392640
});
26402641

26412642
it('message thrown if statusCode != 200 and build is present', async () => {
@@ -2650,10 +2651,10 @@ describe('utils', () => {
26502651
messageType = constant.messageTypes.ERROR;
26512652
errorCode = 'api_failed_build_stop';
26522653
axiosPostStub.resolves(non_200_status_response);
2653-
await utils.stopBrowserStackBuild(bsConfig, args, buildId);
2654+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
26542655
sinon.assert.calledOnce(axiosPostStub);
26552656
sinon.assert.calledOnce(getUserAgentStub);
2656-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
2657+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
26572658
});
26582659

26592660
it('message thrown if API success', async () => {
@@ -2666,10 +2667,10 @@ describe('utils', () => {
26662667
messageType = constant.messageTypes.SUCCESS;
26672668
errorCode = null;
26682669
axiosPostStub.resolves(success_response);
2669-
await utils.stopBrowserStackBuild(bsConfig, args, buildId);
2670+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
26702671
sinon.assert.calledOnce(axiosPostStub);
26712672
sinon.assert.calledOnce(getUserAgentStub);
2672-
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
2673+
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode, null, rawArgs);
26732674
});
26742675
});
26752676

0 commit comments

Comments
 (0)