|
| 1 | +const { expect } = require("chai"); |
1 | 2 | const chai = require("chai"),
|
2 | 3 | chaiAsPromised = require("chai-as-promised"),
|
3 |
| - sinon = require('sinon'); |
| 4 | + sinon = require('sinon'), |
| 5 | + rewire = require('rewire'), |
| 6 | + axios = require('axios'); |
4 | 7 |
|
5 | 8 | const fs = require('fs'),
|
6 | 9 | path = require('path'),
|
@@ -269,4 +272,69 @@ describe("reportHTML", () => {
|
269 | 272 | sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);
|
270 | 273 | });
|
271 | 274 | });
|
| 275 | + |
| 276 | + describe("Modify Cypress Report Data", ()=> { |
| 277 | + const reporterHTML = rewire('../../../../bin/helpers/reporterHTML'); |
| 278 | + const cypressReportData = reporterHTML.__get__('cypressReportData'); |
| 279 | + const cypress_report_data = { |
| 280 | + rows: { |
| 281 | + "todo.spec.js": { |
| 282 | + "sessions": [ |
| 283 | + { |
| 284 | + "tests": { |
| 285 | + "config_json": "config_json", |
| 286 | + "result_json": "result_json", |
| 287 | + } |
| 288 | + } |
| 289 | + ] |
| 290 | + } |
| 291 | + } |
| 292 | + } |
| 293 | + it("Generate Report Data for each combination in a separate promise ", async ()=>{ |
| 294 | + let configResponse = { data: { |
| 295 | + tests: [ |
| 296 | + { |
| 297 | + clientId: "r3", |
| 298 | + title:[ |
| 299 | + "file_name", |
| 300 | + "test_case" |
| 301 | + ] |
| 302 | + } |
| 303 | + ] |
| 304 | + } } |
| 305 | + let resultsResponse = { data: { |
| 306 | + tests: [ |
| 307 | + { |
| 308 | + clientId: "r3", |
| 309 | + state: "passed", |
| 310 | + attempts:[ |
| 311 | + { |
| 312 | + "state": "passed", |
| 313 | + "wallClockDuration": 62 |
| 314 | + } |
| 315 | + ] |
| 316 | + } |
| 317 | + ] |
| 318 | + } } |
| 319 | + let expectedResponse = { |
| 320 | + rows:{ |
| 321 | + "todo.spec.js": { |
| 322 | + "sessions":[{ |
| 323 | + "tests":[{ |
| 324 | + "name":"test_case", |
| 325 | + "status":"passed", |
| 326 | + "duration":"0.06"}] |
| 327 | + }] |
| 328 | + } |
| 329 | + } |
| 330 | + } |
| 331 | + let axiosGetStub = sandbox.stub(axios, "get") |
| 332 | + let axiosConfigStub = axiosGetStub.withArgs("config_json").resolves(configResponse); |
| 333 | + let axiosResultStub = axiosGetStub.withArgs("result_json").resolves(resultsResponse); |
| 334 | + let result = await cypressReportData(cypress_report_data); |
| 335 | + sinon.assert.calledOnce(axiosConfigStub); |
| 336 | + sinon.assert.calledOnce(axiosResultStub); |
| 337 | + expect(JSON.stringify(result)).to.be.equal(JSON.stringify(expectedResponse)); |
| 338 | + }); |
| 339 | + }); |
272 | 340 | });
|
0 commit comments