1
1
/* global describe it expect before beforeEach afterEach */
2
2
require ( 'mocha' ) ;
3
3
require ( 'should' ) ;
4
- const clc = require ( 'cli-color' ) ;
5
4
const fs = require ( 'fs' ) ;
6
- const _ = require ( 'lodash' ) ;
7
- const util = require ( 'util' ) ;
8
5
const sinon = require ( 'sinon' ) ;
9
- const prompt = require ( 'prompt' ) ;
10
6
const rimraf = require ( 'rimraf' ) ;
11
- const process = require ( 'process' ) ;
12
- const fsJson = require ( 'fs-json' ) ( ) ;
13
7
const expect = require ( 'chai' ) . expect ;
14
- const bddStdin = require ( 'bdd-stdin' ) ;
15
8
const proxyquire = require ( 'proxyquire' ) ;
16
9
const changeCase = require ( 'change-case' ) ;
17
10
18
11
const fakeHelpers = require ( './helpers/fakeHelpers' ) ;
19
12
20
13
const {
21
14
dummySession,
22
- dummySessions,
23
15
dummyTestPass,
24
16
dummyTestFail
25
17
} = require ( './helpers/dummyData' ) ;
@@ -39,15 +31,14 @@ const test = proxyquire('../controller/test', {
39
31
} ) ;
40
32
41
33
const projectsDirectory = './test/files/environment/projects' ;
42
- const projectEntriesPath =
43
- './test/files/workenvironmentspace/projects/projects.json' ;
44
34
45
35
describe ( 'test' , function ( ) {
46
36
before ( function ( done ) {
47
37
rimraf ( projectsDirectory , ( ) => done ( ) ) ;
48
38
} ) ;
49
39
50
40
afterEach ( function ( ) {
41
+ // @ts -ignore
51
42
if ( console . log . restore ) console . log . restore ( ) ;
52
43
} ) ;
53
44
@@ -135,17 +126,29 @@ describe('test', function () {
135
126
const log = sinon . spy ( console , 'log' ) ;
136
127
passTests ( project ) . then ( function ( result ) {
137
128
const stats = result . testResults . stats ;
129
+ const { failures, passes, pending, tests } = stats ;
130
+
138
131
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"
140
134
) . to . be . true ;
141
135
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'
143
140
) . to . be . true ;
144
141
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'
146
146
) . to . be . true ;
147
147
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'
149
152
) . to . be . true ;
150
153
done ( ) ;
151
154
} ) ;
@@ -155,17 +158,29 @@ describe('test', function () {
155
158
const log = sinon . spy ( console , 'log' ) ;
156
159
failTests ( project ) . then ( function ( result ) {
157
160
const stats = result . testResults . stats ;
161
+ const { failures, passes, pending, tests } = stats ;
162
+
158
163
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"
160
166
) . to . be . true ;
161
167
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'
163
172
) . to . be . true ;
164
173
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'
166
178
) . to . be . true ;
167
179
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'
169
184
) . to . be . true ;
170
185
done ( ) ;
171
186
} ) ;
0 commit comments