Skip to content

Commit 08fa11f

Browse files
committed
Fix os test output tests
1 parent a429641 commit 08fa11f

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

Diff for: test/test-test.js

+33-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
/* global describe it expect before beforeEach afterEach */
22
require('mocha');
33
require('should');
4-
const clc = require('cli-color');
54
const fs = require('fs');
6-
const _ = require('lodash');
7-
const util = require('util');
85
const sinon = require('sinon');
9-
const prompt = require('prompt');
106
const rimraf = require('rimraf');
11-
const process = require('process');
12-
const fsJson = require('fs-json')();
137
const expect = require('chai').expect;
14-
const bddStdin = require('bdd-stdin');
158
const proxyquire = require('proxyquire');
169
const changeCase = require('change-case');
1710

1811
const fakeHelpers = require('./helpers/fakeHelpers');
1912

2013
const {
2114
dummySession,
22-
dummySessions,
2315
dummyTestPass,
2416
dummyTestFail
2517
} = require('./helpers/dummyData');
@@ -39,15 +31,14 @@ const test = proxyquire('../controller/test', {
3931
});
4032

4133
const projectsDirectory = './test/files/environment/projects';
42-
const projectEntriesPath =
43-
'./test/files/workenvironmentspace/projects/projects.json';
4434

4535
describe('test', function () {
4636
before(function (done) {
4737
rimraf(projectsDirectory, () => done());
4838
});
4939

5040
afterEach(function () {
41+
// @ts-ignore
5142
if (console.log.restore) console.log.restore();
5243
});
5344

@@ -135,17 +126,29 @@ describe('test', function () {
135126
const log = sinon.spy(console, 'log');
136127
passTests(project).then(function (result) {
137128
const stats = result.testResults.stats;
129+
const { failures, passes, pending, tests } = stats;
130+
138131
expect(
139-
log.calledWith(clc.bgBlack.white(' Total tests: 4 '))
132+
log.calledWith(sinon.match(new RegExp(`Total tests:\\W+${tests}`))),
133+
"should include 'Total' test count"
140134
).to.be.true;
141135
expect(
142-
log.calledWith(clc.bgBlue.white(' Passing tests: 4 '))
136+
log.calledWith(
137+
sinon.match(new RegExp(`Passing tests:\\W+${passes}`))
138+
),
139+
'should include "Passing" test count'
143140
).to.be.true;
144141
expect(
145-
log.calledWith(clc.bgYellow.black(' Pending tests: 0 '))
142+
log.calledWith(
143+
sinon.match(new RegExp(`Pending tests:\\W+${pending}`))
144+
),
145+
'should include "Pending" test count'
146146
).to.be.true;
147147
expect(
148-
log.calledWith(clc.bgRed.white(' Failing tests: 0 '))
148+
log.calledWith(
149+
sinon.match(new RegExp(`Failing tests:\\W+${failures}`))
150+
),
151+
'should include "Failing" test count'
149152
).to.be.true;
150153
done();
151154
});
@@ -155,17 +158,29 @@ describe('test', function () {
155158
const log = sinon.spy(console, 'log');
156159
failTests(project).then(function (result) {
157160
const stats = result.testResults.stats;
161+
const { failures, passes, pending, tests } = stats;
162+
158163
expect(
159-
log.calledWith(clc.bgBlack.white(' Total tests: 4 '))
164+
log.calledWith(sinon.match(new RegExp(`Total tests:\\W+${tests}`))),
165+
"should include 'Total' test count"
160166
).to.be.true;
161167
expect(
162-
log.calledWith(clc.bgBlue.white(' Passing tests: 0 '))
168+
log.calledWith(
169+
sinon.match(new RegExp(`Passing tests:\\W+${passes}`))
170+
),
171+
'should include "Passing" test count'
163172
).to.be.true;
164173
expect(
165-
log.calledWith(clc.bgYellow.black(' Pending tests: 0 '))
174+
log.calledWith(
175+
sinon.match(new RegExp(`Pending tests:\\W+${pending}`))
176+
),
177+
'should include "Pending" test count'
166178
).to.be.true;
167179
expect(
168-
log.calledWith(clc.bgRed.white(' Failing tests: 4 '))
180+
log.calledWith(
181+
sinon.match(new RegExp(`Failing tests:\\W+${failures}`))
182+
),
183+
'should include "Failing" test count'
169184
).to.be.true;
170185
done();
171186
});

0 commit comments

Comments
 (0)