1
1
function getAllTests ( suite ) {
2
2
var childSuiteTests = suite . childSuites
3
3
. map ( ( childSuite ) => getAllTests ( childSuite ) )
4
- . reduce ( ( allTests , a ) => allTests . concat ( a ) , [ ] )
4
+ . reduce ( ( allTests , a ) => allTests . concat ( a ) , [ ] ) ;
5
5
6
- return suite . tests . concat ( childSuiteTests )
6
+ return suite . tests . concat ( childSuiteTests ) ;
7
7
}
8
8
9
9
function getRuntime ( suite ) {
10
10
if ( suite . status === 'skipped' || suite . status === undefined ) {
11
- return undefined
11
+ return undefined ;
12
12
}
13
13
14
14
return getAllTests ( suite )
15
15
. map ( ( test ) => test . status === 'skipped' ? 0 : test . runtime )
16
- . reduce ( ( sum , testRuntime ) => sum + testRuntime , 0 )
16
+ . reduce ( ( sum , testRuntime ) => sum + testRuntime , 0 ) ;
17
17
}
18
18
19
19
function getStatus ( suite ) {
20
- var passed = 0
21
- var failed = 0
22
- var skipped = 0
23
- var todo = 0
24
- var tests = getAllTests ( suite )
20
+ var passed = 0 ;
21
+ var failed = 0 ;
22
+ var skipped = 0 ;
23
+ var todo = 0 ;
24
+ var tests = getAllTests ( suite ) ;
25
25
26
26
for ( let i = 0 ; i < tests . length ; i ++ ) {
27
- let test = tests [ i ]
27
+ let test = tests [ i ] ;
28
28
29
29
// If a suite contains a test whose status is still undefined,
30
30
// there is no final status for the suite as well.
31
31
if ( test . status === undefined ) {
32
- return undefined
32
+ return undefined ;
33
33
} else if ( test . status === 'passed' ) {
34
- passed ++
34
+ passed ++ ;
35
35
} else if ( test . status === 'skipped' ) {
36
- skipped ++
36
+ skipped ++ ;
37
37
} else if ( test . status === 'todo' ) {
38
- todo ++
38
+ todo ++ ;
39
39
} else {
40
- failed ++
40
+ failed ++ ;
41
41
}
42
42
}
43
43
44
44
if ( failed > 0 ) {
45
- return 'failed'
45
+ return 'failed' ;
46
46
} else if ( skipped > 0 && passed === 0 ) {
47
- return 'skipped'
47
+ return 'skipped' ;
48
48
} else if ( todo > 0 && passed === 0 ) {
49
- return 'todo'
49
+ return 'todo' ;
50
50
} else {
51
- return 'passed'
51
+ return 'passed' ;
52
52
}
53
53
}
54
54
55
55
function getSuiteStartTestCounts ( suite ) {
56
- var tests = getAllTests ( suite )
56
+ var tests = getAllTests ( suite ) ;
57
57
58
58
return {
59
59
total : tests . length
60
- }
60
+ } ;
61
61
}
62
62
63
63
function getSuiteEndTestCounts ( suite ) {
64
- var tests = getAllTests ( suite )
64
+ var tests = getAllTests ( suite ) ;
65
65
66
66
return {
67
67
passed : tests . filter ( ( test ) => test . status === 'passed' ) . length ,
68
68
failed : tests . filter ( ( test ) => test . status === 'failed' ) . length ,
69
69
skipped : tests . filter ( ( test ) => test . status === 'skipped' ) . length ,
70
70
todo : tests . filter ( ( test ) => test . status === 'todo' ) . length ,
71
71
total : tests . length
72
- }
72
+ } ;
73
73
}
74
74
75
75
export class Assertion {
@@ -82,12 +82,12 @@ export class Assertion {
82
82
* @param {Boolean } todo
83
83
*/
84
84
constructor ( passed , actual , expected , message , stack , todo ) {
85
- this . passed = passed
86
- this . actual = actual
87
- this . expected = expected
88
- this . message = message
89
- this . stack = stack
90
- this . todo = todo
85
+ this . passed = passed ;
86
+ this . actual = actual ;
87
+ this . expected = expected ;
88
+ this . message = message ;
89
+ this . stack = stack ;
90
+ this . todo = todo ;
91
91
}
92
92
}
93
93
@@ -98,9 +98,9 @@ export class TestStart {
98
98
* @param {String[] } fullName
99
99
*/
100
100
constructor ( name , suiteName , fullName ) {
101
- this . name = name
102
- this . suiteName = suiteName
103
- this . fullName = fullName
101
+ this . name = name ;
102
+ this . suiteName = suiteName ;
103
+ this . fullName = fullName ;
104
104
}
105
105
}
106
106
@@ -115,13 +115,13 @@ export class TestEnd {
115
115
* @param {Assertion[] } assertions
116
116
*/
117
117
constructor ( name , suiteName , fullName , status , runtime , errors , assertions ) {
118
- this . name = name
119
- this . suiteName = suiteName
120
- this . fullName = fullName
121
- this . status = status
122
- this . runtime = runtime
123
- this . errors = errors
124
- this . assertions = assertions
118
+ this . name = name ;
119
+ this . suiteName = suiteName ;
120
+ this . fullName = fullName ;
121
+ this . status = status ;
122
+ this . runtime = runtime ;
123
+ this . errors = errors ;
124
+ this . assertions = assertions ;
125
125
}
126
126
}
127
127
@@ -133,11 +133,11 @@ export class SuiteStart {
133
133
* @param {Suite[] } childSuites
134
134
*/
135
135
constructor ( name , fullName , tests , childSuites , testCounts ) {
136
- this . name = name
137
- this . fullName = fullName
138
- this . tests = tests
139
- this . childSuites = childSuites
140
- this . testCounts = getSuiteStartTestCounts ( this )
136
+ this . name = name ;
137
+ this . fullName = fullName ;
138
+ this . tests = tests ;
139
+ this . childSuites = childSuites ;
140
+ this . testCounts = getSuiteStartTestCounts ( this ) ;
141
141
}
142
142
}
143
143
@@ -157,12 +157,12 @@ export class SuiteEnd {
157
157
*/
158
158
constructor ( name , fullName , tests , childSuites , status , testCounts ,
159
159
runtime ) {
160
- this . name = name
161
- this . fullName = fullName
162
- this . tests = tests
163
- this . childSuites = childSuites
164
- this . status = status || getStatus ( this )
165
- this . testCounts = testCounts || getSuiteEndTestCounts ( this )
166
- this . runtime = runtime || getRuntime ( this )
160
+ this . name = name ;
161
+ this . fullName = fullName ;
162
+ this . tests = tests ;
163
+ this . childSuites = childSuites ;
164
+ this . status = status || getStatus ( this ) ;
165
+ this . testCounts = testCounts || getSuiteEndTestCounts ( this ) ;
166
+ this . runtime = runtime || getRuntime ( this ) ;
167
167
}
168
168
}
0 commit comments