Skip to content

Commit 14e97bf

Browse files
committed
Added more tests for specific cases and exit code status
1 parent f54e33d commit 14e97bf

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

bin/helpers/sync/failedSpecsDetails.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
const { table, getBorderCharacters } = require('table'),
2-
chalk = require('chalk');
1+
const tablePrinter = require('table'), // { table, getBorderCharacters }
2+
chalk = require('chalk'),
3+
Constants = require("../constants"),
4+
logger = require("../logger").syncCliLogger;
35

46
/**
57
*
@@ -36,7 +38,7 @@ let failedSpecsDetails = (data) => {
3638
});
3739

3840
let config = {
39-
border: getBorderCharacters('ramac'),
41+
border: tablePrinter.getBorderCharacters('ramac'),
4042
columns: {
4143
0: { alignment: 'left' },
4244
1: { alignment: 'left' },
@@ -54,7 +56,7 @@ let failedSpecsDetails = (data) => {
5456
}
5557
}
5658

57-
let result = table(specData, config);
59+
let result = tablePrinter.table(specData, config);
5860

5961
logger.info('Failed / skipped test report');
6062
logger.info(result);

test/unit/bin/helpers/sync/failedSpecDetails.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
'use strict';
22
const chai = require("chai"),
33
expect = chai.expect,
4-
sinon = require('sinon'),
5-
chaiAsPromised = require("chai-as-promised"),
6-
fs = require('fs');
4+
chaiAsPromised = require("chai-as-promised");
75

6+
chai.use(chaiAsPromised);
87
const specDetails = require('../../../../../bin/helpers/sync/failedSpecsDetails');
98

109
describe("failedSpecsDetails", () => {
1110
context("data is empty", () => {
1211
let data = [];
1312
it('returns 0 exit code', () => {
14-
specDetails.failedSpecsDetails(data).then((status) => {
15-
chai.assert.equal(data, 0);
13+
return specDetails.failedSpecsDetails(data).then((status) => {
14+
expect(status).to.equal(0);
1615
});
1716
});
1817
});
@@ -23,8 +22,24 @@ describe("failedSpecsDetails", () => {
2322
];
2423

2524
it("returns 0 exit code", () => {
26-
specDetails.failedSpecsDetails(data).then((status) => {
27-
chai.assert.equal(data, 0);
25+
return specDetails.failedSpecsDetails(data).then((status) => {
26+
expect(status).to.equal(0);
27+
});
28+
});
29+
});
30+
31+
context("data has failed specs", () => {
32+
let data = [
33+
{specName: 'spec2.name.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'}
34+
];
35+
36+
it("returns 1 exit code", () => {
37+
return specDetails.failedSpecsDetails(data)
38+
.then((status) => {
39+
chai.assert.equal(status, 1);
40+
expect(status).to.equal(1);
41+
}).catch((status) => {
42+
expect(status).to.equal(1);
2843
});
2944
});
3045
});

0 commit comments

Comments
 (0)