|
@@ -25,23 +25,30 @@ export default class Reporter extends Component {
|
25
|
25
|
}
|
26
|
26
|
|
27
|
27
|
renderTests() {
|
28
|
|
- return this.props.context.tests.map((t, i) => {
|
|
28
|
+ let tests = this.props.context.tests
|
|
29
|
+ return tests.map((t, i) => {
|
29
|
30
|
|
30
|
31
|
let pass = true
|
31
|
|
- let foundAssertions = false
|
|
32
|
+ let foundActions = false
|
32
|
33
|
|
33
|
|
- if(Array.isArray(t.result)) {
|
|
34
|
+ if(Array.isArray(t.result) && !t.expired) {
|
34
|
35
|
t.result = t.result.map((r) => {
|
35
|
|
- if(r.type.name === 'Assert') {
|
36
|
|
- foundAssertions = true
|
|
36
|
+ if(r.type.name === 'Assert' || r.type.name === 'Info') {
|
|
37
|
+ foundActions = true
|
37
|
38
|
let comp = r.props.comparer ? r.props.comparer(r.props.expect, r.props.actual) : (r.props.actual === r.props.expect)
|
38
|
39
|
pass = pass && comp
|
39
|
40
|
}
|
40
|
41
|
return React.cloneElement(r, {desc : r.key})
|
41
|
42
|
})
|
42
|
43
|
}
|
43
|
|
-
|
44
|
|
- t.status = foundAssertions ? (pass ? 'pass' : 'fail') : 'pass'
|
|
44
|
+ if(tests[i].running)
|
|
45
|
+ t.status = 'running'
|
|
46
|
+ else if(this.props.context.tests[i].executed) {
|
|
47
|
+ t.status = foundActions ? (pass ? 'pass' : 'fail') : 'skipped'
|
|
48
|
+ t.status = t.expired ? 'timeout' : t.status
|
|
49
|
+ }
|
|
50
|
+ else
|
|
51
|
+ t.status = 'waiting'
|
45
|
52
|
|
46
|
53
|
return (<View key={'rn-test-' + t.desc} style={{
|
47
|
54
|
borderBottomWidth : 1.5,
|
|
@@ -52,7 +59,7 @@ export default class Reporter extends Component {
|
52
|
59
|
flexDirection : 'row'
|
53
|
60
|
}}>
|
54
|
61
|
<Text style={[styles.badge, {flex : 1, borderWidth : 0, textAlign : 'left'}]}>{t.desc}</Text>
|
55
|
|
- <Text style={[styles.badge, this.getBadge(t.status)]}>{t.status ? 'pass' : 'fail'}</Text>
|
|
62
|
+ <Text style={[styles.badge, this.getBadge(t.status)]}>{t.status}</Text>
|
56
|
63
|
</View>
|
57
|
64
|
<View key={t.desc + '-result'} style={{backgroundColor : '#F4F4F4'}}>
|
58
|
65
|
{t.result}
|
|
@@ -61,13 +68,8 @@ export default class Reporter extends Component {
|
61
|
68
|
})
|
62
|
69
|
}
|
63
|
70
|
|
64
|
|
- getBadge(status: 'running' | 'pass' | 'fail') {
|
65
|
|
- if(status === 'running')
|
66
|
|
- return styles.badgeWaiting
|
67
|
|
- else if(status === 'pass')
|
68
|
|
- return styles.badgePass
|
69
|
|
- else
|
70
|
|
- return styles.badgeFail
|
|
71
|
+ getBadge(status: 'waiting' | 'running' | 'pass' | 'fail' | 'timeout') {
|
|
72
|
+ return styles[status]
|
71
|
73
|
}
|
72
|
74
|
|
73
|
75
|
}
|
|
@@ -84,15 +86,27 @@ const styles = StyleSheet.create({
|
84
|
86
|
borderWidth : 2,
|
85
|
87
|
textAlign : 'center'
|
86
|
88
|
},
|
87
|
|
- badgePass: {
|
|
89
|
+ skipped: {
|
|
90
|
+ borderColor : '#AAAAAA',
|
|
91
|
+ color : '#AAAAAA'
|
|
92
|
+ },
|
|
93
|
+ waiting: {
|
|
94
|
+ borderColor : '#AAAAAA',
|
|
95
|
+ color : '#AAAAAA'
|
|
96
|
+ },
|
|
97
|
+ pass: {
|
88
|
98
|
borderColor : '#00a825',
|
89
|
99
|
color : '#00a825'
|
90
|
100
|
},
|
91
|
|
- badgeWaiting: {
|
|
101
|
+ running: {
|
92
|
102
|
borderColor : '#e3c423',
|
93
|
103
|
color : '#e3c423'
|
94
|
104
|
},
|
95
|
|
- badgeFail: {
|
|
105
|
+ fail: {
|
|
106
|
+ borderColor : '#ff0d0d',
|
|
107
|
+ color : '#ff0d0d'
|
|
108
|
+ },
|
|
109
|
+ timeout: {
|
96
|
110
|
borderColor : '#ff0d0d',
|
97
|
111
|
color : '#ff0d0d'
|
98
|
112
|
}
|