browserstack-cypress-cli 1.8.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/4a952689-f098-4108-8a3e-26deb80519a8.json +1 -0
- package/.nyc_output/97ba506f-6310-4b5c-b0cf-54cdd82c7af6.json +1 -0
- package/.nyc_output/processinfo/4a952689-f098-4108-8a3e-26deb80519a8.json +1 -0
- package/.nyc_output/processinfo/97ba506f-6310-4b5c-b0cf-54cdd82c7af6.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/bin/commands/generateDownloads.js +39 -0
- package/bin/commands/generateReport.js +1 -0
- package/bin/commands/info.js +1 -0
- package/bin/commands/runs.js +186 -60
- package/bin/commands/stop.js +3 -63
- package/bin/helpers/archiver.js +5 -20
- package/bin/helpers/buildArtifacts.js +220 -0
- package/bin/helpers/capabilityHelper.js +15 -22
- package/bin/helpers/checkUploaded.js +153 -0
- package/bin/helpers/config.js +3 -0
- package/bin/helpers/constants.js +98 -13
- package/bin/helpers/fileHelpers.js +14 -0
- package/bin/helpers/hashUtil.js +70 -0
- package/bin/helpers/packageInstaller.js +138 -0
- package/bin/helpers/reporterHTML.js +117 -9
- package/bin/helpers/sync/syncSpecsLogs.js +36 -8
- package/bin/helpers/timeComponents.js +71 -0
- package/bin/helpers/usageReporting.js +5 -4
- package/bin/helpers/utils.js +388 -9
- package/bin/helpers/zipUpload.js +42 -24
- package/bin/runner.js +108 -113
- package/package.json +6 -2
- package/test/test_files/dummy_bstack.json +0 -0
- package/test/test_files/dummy_bstack_2.json +0 -1
- package/test/test_files/dummy_bstack_3.json +0 -3
- package/test/unit/bin/commands/generateReport.js +0 -112
- package/test/unit/bin/commands/info.js +0 -374
- package/test/unit/bin/commands/init.js +0 -187
- package/test/unit/bin/commands/runs.js +0 -700
- package/test/unit/bin/commands/stop.js +0 -388
- package/test/unit/bin/helpers/archiver.js +0 -57
- package/test/unit/bin/helpers/build.js +0 -210
- package/test/unit/bin/helpers/capabilityHelper.js +0 -1049
- package/test/unit/bin/helpers/fileHelpers.js +0 -102
- package/test/unit/bin/helpers/reporterHTML.js +0 -272
- package/test/unit/bin/helpers/sync/failedSpecDetails.js +0 -76
- package/test/unit/bin/helpers/sync/specSummary.js +0 -55
- package/test/unit/bin/helpers/sync/syncSpecsLogs.js +0 -403
- package/test/unit/bin/helpers/usageReporting.js +0 -411
- package/test/unit/bin/helpers/utils.js +0 -1743
- package/test/unit/bin/helpers/zipUpload.js +0 -205
- package/test/unit/support/fixtures/testObjects.js +0 -149
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const chai = require("chai"),
|
|
3
|
-
expect = chai.expect,
|
|
4
|
-
rewire = require("rewire"),
|
|
5
|
-
chaiAsPromised = require("chai-as-promised"),
|
|
6
|
-
chalk = require('chalk'),
|
|
7
|
-
request = require("request");
|
|
8
|
-
|
|
9
|
-
const sinon = require("sinon");
|
|
10
|
-
|
|
11
|
-
chai.use(chaiAsPromised);
|
|
12
|
-
|
|
13
|
-
var syncSpecsLogs = rewire("../../../../../bin/helpers/sync/syncSpecsLogs.js");
|
|
14
|
-
var logger = require("../../../../../bin/helpers/logger").syncCliLogger;
|
|
15
|
-
var Constants = require("../../../../../bin/helpers/constants.js");
|
|
16
|
-
var config = require("../../../../../bin/helpers/config.js");
|
|
17
|
-
|
|
18
|
-
describe("syncSpecsLogs", () => {
|
|
19
|
-
var sandbox;
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
sandbox = sinon.createSandbox();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
sandbox.restore();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
context("getCombinationName", () => {
|
|
30
|
-
const get_path = syncSpecsLogs.__get__("getCombinationName");;
|
|
31
|
-
let spec = {
|
|
32
|
-
"os": "Windows",
|
|
33
|
-
"osVersion": "10",
|
|
34
|
-
"browser": "chrome",
|
|
35
|
-
"browserVersion": "86"
|
|
36
|
-
}
|
|
37
|
-
it("returns combination name", () => {
|
|
38
|
-
let expectedCombination = `Chrome 86 (Windows 10)`;
|
|
39
|
-
expect(get_path(spec)).to.equal(expectedCombination);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
context("getStatus", () => {
|
|
44
|
-
const getStatus = syncSpecsLogs.__get__("getStatus");;
|
|
45
|
-
|
|
46
|
-
it("returns return ✔ in green when status is passes", () => {
|
|
47
|
-
expect(getStatus("passed")).to.equal(chalk.green("✔"));
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("returns return ✘ in red when status is failed", () => {
|
|
51
|
-
expect(getStatus("failed")).to.equal(chalk.red("✘"));
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns return [status] in yellow when status is skipped or ignored (anything else from pass/fail)", () => {
|
|
55
|
-
expect(getStatus("skipped")).to.equal(chalk.blue("[skipped]"));
|
|
56
|
-
expect(getStatus("ignored")).to.equal(chalk.blue("[ignored]"));
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
context("printInitialLog", () => {
|
|
61
|
-
const printInitialLog = syncSpecsLogs.__get__("printInitialLog");
|
|
62
|
-
|
|
63
|
-
it("should print inital logs for specs in sync", () => {
|
|
64
|
-
|
|
65
|
-
printInitialLog()
|
|
66
|
-
|
|
67
|
-
expect(syncSpecsLogs.__get__("n")).to.equal(Constants.syncCLI.INITIAL_DELAY_MULTIPLIER);
|
|
68
|
-
expect(syncSpecsLogs.__get__("startTime")).to.not.be.null;
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
context("getOptions", () => {
|
|
74
|
-
const getOptions = syncSpecsLogs.__get__("getOptions");
|
|
75
|
-
let auth = {username: "cypress", access_key: "abcd"}
|
|
76
|
-
let build_id = "build1"
|
|
77
|
-
|
|
78
|
-
it('should return proper request option for polling', () => {
|
|
79
|
-
let options = getOptions(auth, build_id);
|
|
80
|
-
expect(options.url).to.equal(`${config.buildUrl}${build_id}`);
|
|
81
|
-
expect(options.auth.user).to.equal(auth.username);
|
|
82
|
-
expect(options.auth.password).to.equal(auth.access_key);
|
|
83
|
-
expect(options.headers["Content-Type"]).to.equal("application/json");
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
context("getTableConfig", () => {
|
|
88
|
-
const getTableConfig = syncSpecsLogs.__get__("getTableConfig");
|
|
89
|
-
|
|
90
|
-
it('should return proper table config option for spec table', () => {
|
|
91
|
-
var getBorderConfigStub = sandbox.stub();
|
|
92
|
-
syncSpecsLogs.__set__('getBorderConfig', getBorderConfigStub);
|
|
93
|
-
|
|
94
|
-
let options = getTableConfig();
|
|
95
|
-
expect(options.columnDefault.width).to.equal(30);
|
|
96
|
-
expect(options.columns[1].alignment).to.equal('center');
|
|
97
|
-
expect(options.columns[2].alignment).to.equal('left');
|
|
98
|
-
expect(options.columns[1].width).to.equal(1);
|
|
99
|
-
expect(options.columns[2].width).to.equal(100);
|
|
100
|
-
expect(options.columnCount).to.equal(3);
|
|
101
|
-
expect(getBorderConfigStub.calledOnce).to.be.true;
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
context("getBorderConfig", () => {
|
|
106
|
-
const getBorderConfig = syncSpecsLogs.__get__("getBorderConfig");
|
|
107
|
-
|
|
108
|
-
it('should return proper border option for spec table', () => {
|
|
109
|
-
let options = getBorderConfig();
|
|
110
|
-
expect(options.topBody).to.equal("");
|
|
111
|
-
expect(options.bottomBody).to.equal("");
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
context("writeToTable", () => {
|
|
116
|
-
const writeToTable = syncSpecsLogs.__get__("writeToTable");
|
|
117
|
-
|
|
118
|
-
it('should print spec details to the table', () => {
|
|
119
|
-
const stream = sandbox.stub();
|
|
120
|
-
stream.write = sandbox.stub();
|
|
121
|
-
syncSpecsLogs.__set__('stream', stream);
|
|
122
|
-
let combination = "Windows 10", path = "path", status = "passed";
|
|
123
|
-
writeToTable(combination, path, status);
|
|
124
|
-
sinon.assert.calledOnceWithExactly(stream.write, [combination , ":", `${path} ${status}`]);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
context("addSpecToSummary", () => {
|
|
129
|
-
const addSpecToSummary = syncSpecsLogs.__get__("addSpecToSummary");
|
|
130
|
-
|
|
131
|
-
it('should add spec details to specSummary', () => {
|
|
132
|
-
let specSummary = { specs: [] }
|
|
133
|
-
syncSpecsLogs.__set__('specSummary', specSummary);
|
|
134
|
-
let specName = "spec", status = "status", combination = "combo", session_id = "id";
|
|
135
|
-
addSpecToSummary(specName, status, combination, session_id);
|
|
136
|
-
expect(specSummary.specs).deep.to.equal([{"specName": specName, "status": status, "combination": combination, "sessionId": session_id}])
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
context("printSpecData", () => {
|
|
141
|
-
const printSpecData = syncSpecsLogs.__get__("printSpecData");
|
|
142
|
-
|
|
143
|
-
it('Should print combination and status to the spec table and add spec details to spec array', () => {
|
|
144
|
-
let data = { spec: { status: "passed" }, path: "path", session_id: "id" }
|
|
145
|
-
var getCombinationName = sandbox.stub();
|
|
146
|
-
syncSpecsLogs.__set__('getCombinationName', getCombinationName);
|
|
147
|
-
var getStatus = sandbox.stub();
|
|
148
|
-
syncSpecsLogs.__set__('getStatus', getStatus);
|
|
149
|
-
var writeToTable = sandbox.stub();
|
|
150
|
-
syncSpecsLogs.__set__('writeToTable', writeToTable);
|
|
151
|
-
var addSpecToSummary = sandbox.stub();
|
|
152
|
-
syncSpecsLogs.__set__('addSpecToSummary', addSpecToSummary);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
printSpecData(data);
|
|
156
|
-
sinon.assert.calledOnceWithExactly(getCombinationName, data["spec"]);
|
|
157
|
-
sinon.assert.calledOnceWithExactly(getStatus, data["spec"]["status"]);
|
|
158
|
-
sinon.assert.calledOnce(writeToTable);
|
|
159
|
-
sinon.assert.calledOnce(addSpecToSummary);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
context("showSpecsStatus", () => {
|
|
165
|
-
const showSpecsStatus = syncSpecsLogs.__get__("showSpecsStatus");
|
|
166
|
-
|
|
167
|
-
it('should print initial log for running specs when it is the 1st polling response', () => {
|
|
168
|
-
let data = JSON.stringify(["created"])
|
|
169
|
-
var printInitialLog = sandbox.stub();
|
|
170
|
-
syncSpecsLogs.__set__('printInitialLog', printInitialLog);
|
|
171
|
-
|
|
172
|
-
showSpecsStatus(data);
|
|
173
|
-
|
|
174
|
-
expect(printInitialLog.calledOnce).to.be.true;
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should print spec details when spec related data is sent in polling response', () => {
|
|
178
|
-
let specResult = JSON.stringify({"path": "path"})
|
|
179
|
-
let data = JSON.stringify([specResult])
|
|
180
|
-
var printSpecData = sandbox.stub();
|
|
181
|
-
syncSpecsLogs.__set__('printSpecData', printSpecData);
|
|
182
|
-
showSpecsStatus(data);
|
|
183
|
-
expect(printSpecData.calledOnce).to.be.true;
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('should print initial and spec details when spec related data is sent in polling response', () => {
|
|
187
|
-
let specResult = JSON.stringify({"path": "path"})
|
|
188
|
-
let data = JSON.stringify(["created", specResult])
|
|
189
|
-
var printSpecData = sandbox.stub();
|
|
190
|
-
syncSpecsLogs.__set__('printSpecData', printSpecData);
|
|
191
|
-
var printInitialLog = sandbox.stub();
|
|
192
|
-
syncSpecsLogs.__set__('printInitialLog', printInitialLog);
|
|
193
|
-
showSpecsStatus(data);
|
|
194
|
-
expect(printSpecData.calledOnce).to.be.true;
|
|
195
|
-
expect(printInitialLog.calledOnce).to.be.true;
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
context("printSpecsStatus", () => {
|
|
200
|
-
const printSpecsStatus = syncSpecsLogs.__get__("printSpecsStatus");
|
|
201
|
-
let startTime = Date.now(), endTime = Date.now() + 10, counter = 0;
|
|
202
|
-
let specSummary = { specs: [] }, getOptions, getTableConfig, tableStream, whileProcess;
|
|
203
|
-
|
|
204
|
-
beforeEach(() => {
|
|
205
|
-
counter = 0;
|
|
206
|
-
|
|
207
|
-
getOptions = sandbox.stub();
|
|
208
|
-
syncSpecsLogs.__set__('getOptions', getOptions);
|
|
209
|
-
|
|
210
|
-
getTableConfig = sandbox.stub();
|
|
211
|
-
syncSpecsLogs.__set__('getTableConfig', getTableConfig);
|
|
212
|
-
|
|
213
|
-
tableStream = sandbox.stub();
|
|
214
|
-
syncSpecsLogs.__set__('tableStream', tableStream);
|
|
215
|
-
|
|
216
|
-
whileProcess = sandbox.stub().callsFake(function (whilstCallback) {
|
|
217
|
-
counter++
|
|
218
|
-
if(counter >= 3) {
|
|
219
|
-
syncSpecsLogs.__set__('whileLoop', false);
|
|
220
|
-
whilstCallback(new Error("ggg"), {});
|
|
221
|
-
} else {whileProcess(whilstCallback, 10, null)}
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
syncSpecsLogs.__set__('whileProcess', whileProcess);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('Should not loop when whileLoop is false and set duration correctly', () => {
|
|
228
|
-
syncSpecsLogs.__set__('whileLoop', false);
|
|
229
|
-
syncSpecsLogs.__set__('startTime', startTime);
|
|
230
|
-
syncSpecsLogs.__set__('endTime', endTime);
|
|
231
|
-
syncSpecsLogs.__set__('specSummary', specSummary);
|
|
232
|
-
|
|
233
|
-
return printSpecsStatus({}, {}).then((specSummary) => {
|
|
234
|
-
expect(getOptions.calledOnce).to.be.true;
|
|
235
|
-
expect(getTableConfig.calledOnce).to.be.true;
|
|
236
|
-
expect(tableStream.calledOnce).to.be.true;
|
|
237
|
-
expect(whileProcess.calledOnce).to.be.false;
|
|
238
|
-
expect(specSummary.specs).deep.to.equal([])
|
|
239
|
-
expect(specSummary.duration).to.eql(endTime - startTime);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('Should loop when whileLoop is true until it becomes false', () => {
|
|
244
|
-
syncSpecsLogs.__set__('whileLoop', true);
|
|
245
|
-
syncSpecsLogs.__set__('startTime', startTime);
|
|
246
|
-
syncSpecsLogs.__set__('endTime', endTime);
|
|
247
|
-
syncSpecsLogs.__set__('specSummary', specSummary);
|
|
248
|
-
|
|
249
|
-
return printSpecsStatus({}, {}).then((specSummary) => {
|
|
250
|
-
expect(getOptions.calledOnce).to.be.true;
|
|
251
|
-
expect(getTableConfig.calledOnce).to.be.true;
|
|
252
|
-
expect(tableStream.calledOnce).to.be.true;
|
|
253
|
-
expect(whileProcess.callCount).to.eql(3);
|
|
254
|
-
expect(specSummary.duration).to.eql(endTime - startTime);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
context("whileProcess", () => {
|
|
260
|
-
const whileProcess = syncSpecsLogs.__get__("whileProcess");
|
|
261
|
-
|
|
262
|
-
it('Should retry when request fails with error', () => {
|
|
263
|
-
let delayed_n = 2, timeout = 3000, n = 1;
|
|
264
|
-
let error = new Error("error");
|
|
265
|
-
|
|
266
|
-
let requestStub = sandbox.stub();
|
|
267
|
-
|
|
268
|
-
let postStub = sandbox
|
|
269
|
-
.stub(request, "post")
|
|
270
|
-
.yields(error, { statusCode: 502 }, JSON.stringify({}));
|
|
271
|
-
|
|
272
|
-
requestStub.post = postStub;
|
|
273
|
-
|
|
274
|
-
let setTimeout = sandbox.stub();
|
|
275
|
-
syncSpecsLogs.__set__('setTimeout', setTimeout);
|
|
276
|
-
syncSpecsLogs.__set__('n', n);
|
|
277
|
-
syncSpecsLogs.__set__('timeout', timeout);
|
|
278
|
-
syncSpecsLogs.__set__('request', requestStub);
|
|
279
|
-
syncSpecsLogs.__set__('whileTries', 5);
|
|
280
|
-
|
|
281
|
-
let whilstCallback = sandbox.stub();
|
|
282
|
-
whileProcess(whilstCallback);
|
|
283
|
-
|
|
284
|
-
sinon.assert.calledWith(setTimeout, whilstCallback, timeout * delayed_n, null);
|
|
285
|
-
expect(syncSpecsLogs.__get__("whileTries")).to.equal(4);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('Should exit after defined number of retries in case of error', () => {
|
|
289
|
-
let error = new Error("error"), requestStub = sandbox.stub();
|
|
290
|
-
|
|
291
|
-
let postStub = sandbox
|
|
292
|
-
.stub(request, "post")
|
|
293
|
-
.yields(error, { statusCode: 502 }, JSON.stringify({}));
|
|
294
|
-
|
|
295
|
-
requestStub.post = postStub;
|
|
296
|
-
|
|
297
|
-
syncSpecsLogs.__set__('request', requestStub);
|
|
298
|
-
syncSpecsLogs.__set__('whileTries', 1);
|
|
299
|
-
syncSpecsLogs.__set__('specSummary', {});
|
|
300
|
-
syncSpecsLogs.__set__('whileLoop', true);
|
|
301
|
-
|
|
302
|
-
let whilstCallback = sandbox.stub();
|
|
303
|
-
whileProcess(whilstCallback);
|
|
304
|
-
|
|
305
|
-
sinon.assert.calledWith(whilstCallback, { status: 504, message: "Tries limit reached" });
|
|
306
|
-
expect(syncSpecsLogs.__get__("whileTries")).to.equal(0);
|
|
307
|
-
expect(syncSpecsLogs.__get__("whileLoop")).to.equal(false);
|
|
308
|
-
expect(syncSpecsLogs.__get__("specSummary.exitCode")).to.equal(2);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('Should print spec details when data is returned from server', () => {
|
|
312
|
-
let error = null, body={}, status = 202, n = 1, delayed_n = 2, timeout = 3000;
|
|
313
|
-
let requestStub = sandbox.stub();
|
|
314
|
-
let postStub = sandbox
|
|
315
|
-
.stub(request, "post")
|
|
316
|
-
.yields(error, { statusCode: status }, JSON.stringify(body));
|
|
317
|
-
requestStub.post = postStub;
|
|
318
|
-
syncSpecsLogs.__set__('request', requestStub);
|
|
319
|
-
|
|
320
|
-
let showSpecsStatus = sandbox.stub();
|
|
321
|
-
syncSpecsLogs.__set__('showSpecsStatus', showSpecsStatus);
|
|
322
|
-
|
|
323
|
-
let setTimeout = sandbox.stub();
|
|
324
|
-
syncSpecsLogs.__set__('setTimeout', setTimeout);
|
|
325
|
-
syncSpecsLogs.__set__('n', n);
|
|
326
|
-
syncSpecsLogs.__set__('timeout', timeout);
|
|
327
|
-
|
|
328
|
-
let whilstCallback = sandbox.stub();
|
|
329
|
-
whileProcess(whilstCallback);
|
|
330
|
-
|
|
331
|
-
expect(syncSpecsLogs.__get__("n")).to.equal(delayed_n);
|
|
332
|
-
sinon.assert.calledWith(setTimeout, whilstCallback, timeout * delayed_n, null);
|
|
333
|
-
sinon.assert.calledWith(showSpecsStatus, JSON.stringify(body));
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
it('Should poll for data when server responds with no data available', () => {
|
|
337
|
-
let error = null, body={}, status = 204, n = 1, delayed_n = 1, timeout = 3000;
|
|
338
|
-
let requestStub = sandbox.stub();
|
|
339
|
-
let postStub = sandbox
|
|
340
|
-
.stub(request, "post")
|
|
341
|
-
.yields(error, { statusCode: status }, JSON.stringify(body));
|
|
342
|
-
requestStub.post = postStub;
|
|
343
|
-
syncSpecsLogs.__set__('request', requestStub);
|
|
344
|
-
|
|
345
|
-
let showSpecsStatus = sandbox.stub();
|
|
346
|
-
syncSpecsLogs.__set__('showSpecsStatus', showSpecsStatus);
|
|
347
|
-
|
|
348
|
-
let setTimeout = sandbox.stub();
|
|
349
|
-
syncSpecsLogs.__set__('setTimeout', setTimeout);
|
|
350
|
-
syncSpecsLogs.__set__('n', n);
|
|
351
|
-
syncSpecsLogs.__set__('timeout', timeout);
|
|
352
|
-
|
|
353
|
-
let whilstCallback = sandbox.stub();
|
|
354
|
-
whileProcess(whilstCallback);
|
|
355
|
-
|
|
356
|
-
expect(syncSpecsLogs.__get__("n")).to.equal(delayed_n);
|
|
357
|
-
sinon.assert.calledWith(setTimeout, whilstCallback, timeout * delayed_n, null);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it('Should stop polling for data when server responds build is completed', () => {
|
|
361
|
-
let error = null, body={}, status = 200, n = 1, timeout = 3000;
|
|
362
|
-
let requestStub = sandbox.stub();
|
|
363
|
-
let postStub = sandbox.stub(request, "post").yields(error, { statusCode: status }, JSON.stringify(body));
|
|
364
|
-
requestStub.post = postStub;
|
|
365
|
-
syncSpecsLogs.__set__('request', requestStub);
|
|
366
|
-
|
|
367
|
-
let showSpecsStatus = sandbox.stub();
|
|
368
|
-
syncSpecsLogs.__set__('showSpecsStatus', showSpecsStatus);
|
|
369
|
-
|
|
370
|
-
syncSpecsLogs.__set__('whileLoop', true);
|
|
371
|
-
syncSpecsLogs.__set__('n', n);
|
|
372
|
-
syncSpecsLogs.__set__('timeout', timeout);
|
|
373
|
-
|
|
374
|
-
let whilstCallback = sandbox.stub();
|
|
375
|
-
whileProcess(whilstCallback);
|
|
376
|
-
|
|
377
|
-
expect(syncSpecsLogs.__get__("whileLoop")).to.be.false;
|
|
378
|
-
sinon.assert.calledWith(whilstCallback, null, JSON.stringify(body));
|
|
379
|
-
sinon.assert.calledWith(showSpecsStatus, JSON.stringify(body));
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
it('Should stop polling for data when server responds with error ', () => {
|
|
383
|
-
let error = null, body={}, status = 404, n = 1, timeout = 3000;
|
|
384
|
-
let requestStub = sandbox.stub();
|
|
385
|
-
let postStub = sandbox.stub(request, "post").yields(error, { statusCode: status }, JSON.stringify(body));
|
|
386
|
-
requestStub.post = postStub;
|
|
387
|
-
syncSpecsLogs.__set__('request', requestStub);
|
|
388
|
-
|
|
389
|
-
let showSpecsStatus = sandbox.stub();
|
|
390
|
-
syncSpecsLogs.__set__('showSpecsStatus', showSpecsStatus);
|
|
391
|
-
|
|
392
|
-
syncSpecsLogs.__set__('whileLoop', true);
|
|
393
|
-
syncSpecsLogs.__set__('n', n);
|
|
394
|
-
syncSpecsLogs.__set__('timeout', timeout);
|
|
395
|
-
|
|
396
|
-
let whilstCallback = sandbox.stub();
|
|
397
|
-
whileProcess(whilstCallback);
|
|
398
|
-
|
|
399
|
-
expect(syncSpecsLogs.__get__("whileLoop")).to.be.false;
|
|
400
|
-
sinon.assert.calledWith(whilstCallback, {message: JSON.stringify(body), status: status});
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
});
|