|
@@ -9,6 +9,7 @@ import {
|
9
|
9
|
ListView,
|
10
|
10
|
Image,
|
11
|
11
|
TouchableOpacity,
|
|
12
|
+ Dimensions,
|
12
|
13
|
RecyclerViewBackedScrollView,
|
13
|
14
|
} from 'react-native';
|
14
|
15
|
|
|
@@ -20,9 +21,11 @@ export default class Reporter extends Component {
|
20
|
21
|
constructor(props:any) {
|
21
|
22
|
super(props)
|
22
|
23
|
this.tests = {
|
23
|
|
- summary : [{}],
|
24
|
24
|
common : []
|
25
|
25
|
}
|
|
26
|
+ this.state = {
|
|
27
|
+ listHeight : 0
|
|
28
|
+ }
|
26
|
29
|
this.testGroups = ['summary','common']
|
27
|
30
|
this.ds = null
|
28
|
31
|
this.updateDataSource()
|
|
@@ -35,20 +38,49 @@ export default class Reporter extends Component {
|
35
|
38
|
|
36
|
39
|
render() {
|
37
|
40
|
|
|
41
|
+ let tests = RNTEST.TestContext.getTests()
|
|
42
|
+
|
|
43
|
+ let passed = 0
|
|
44
|
+ let executed = 0
|
|
45
|
+ let count = 0
|
|
46
|
+ for(let i in tests) {
|
|
47
|
+ if(tests[i].status !== 'skipped')
|
|
48
|
+ count++
|
|
49
|
+ if(tests[i].status !== 'waiting' && tests[i].status !== 'skipped')
|
|
50
|
+ executed++
|
|
51
|
+ passed += tests[i].status === 'pass' ? 1 : 0
|
|
52
|
+ }
|
|
53
|
+ let percent = passed / count
|
|
54
|
+ let color = `rgb(${Math.floor((1-percent) *255)},${Math.floor(percent *255)}, 0)`
|
|
55
|
+
|
38
|
56
|
return (
|
39
|
|
- <ListView
|
40
|
|
- style={styles.container}
|
41
|
|
- dataSource={this.ds}
|
42
|
|
- renderRow={this.renderTest.bind(this)}
|
43
|
|
- renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
|
44
|
|
- renderSectionHeader={(data, id) => {
|
45
|
|
- return (
|
46
|
|
- <View style={styles.sectionHeader}>
|
47
|
|
- <Text style={styles.sectionText}>{id}</Text>
|
48
|
|
- </View>
|
49
|
|
- )
|
50
|
|
- }}
|
51
|
|
- />)
|
|
57
|
+ <View style={{flex : 1}}>
|
|
58
|
+ <View style={{margin : 20}} onLayout={(e) => {
|
|
59
|
+ this.setState({
|
|
60
|
+ headerHeight : e.nativeEvent.layout.height,
|
|
61
|
+ listHeight : Dimensions.get('window').height - e.nativeEvent.layout.height
|
|
62
|
+ })
|
|
63
|
+ }}>
|
|
64
|
+ <Text>{`${executed} tests executed`}</Text>
|
|
65
|
+ <Text>{`${passed} test cases passed`}</Text>
|
|
66
|
+ <Text>{`${count} test cases`}</Text>
|
|
67
|
+ <Text style={{color, fontSize : 120, textAlign : 'center'}} >{`${Math.floor(percent*100)}`}</Text>
|
|
68
|
+ <Text style={{color, fontSize : 30, textAlign :'right', marginTop : -54, marginRight : 40, backgroundColor : 'transparent'}} >{`%`}</Text>
|
|
69
|
+ </View>
|
|
70
|
+ <ListView
|
|
71
|
+ style={[styles.container]}
|
|
72
|
+ dataSource={this.ds}
|
|
73
|
+ renderRow={this.renderTest.bind(this)}
|
|
74
|
+ renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
|
|
75
|
+ renderSectionHeader={(data, id) => {
|
|
76
|
+ return (
|
|
77
|
+ <View style={styles.sectionHeader}>
|
|
78
|
+ <Text style={styles.sectionText}>{id}</Text>
|
|
79
|
+ </View>
|
|
80
|
+ )
|
|
81
|
+ }}
|
|
82
|
+ />
|
|
83
|
+ </View>)
|
52
|
84
|
}
|
53
|
85
|
|
54
|
86
|
renderTest(t, group) {
|
|
@@ -57,23 +89,6 @@ export default class Reporter extends Component {
|
57
|
89
|
let foundActions = false
|
58
|
90
|
let tests = RNTEST.TestContext.getTests()
|
59
|
91
|
|
60
|
|
- if(group === 'summary')
|
61
|
|
- {
|
62
|
|
- let passed = 0
|
63
|
|
- let executed = 0
|
64
|
|
- let count = 0
|
65
|
|
- for(let i in tests) {
|
66
|
|
- count++
|
67
|
|
- if(tests[i].executed)
|
68
|
|
- passed += tests[i].status === 'pass' ? 1 : 0
|
69
|
|
- }
|
70
|
|
- return (<View style={{flex : 1}}>
|
71
|
|
- <Text>{`${count} test cases`}</Text>
|
72
|
|
- <Text>{`${executed} tests executed`}</Text>
|
73
|
|
- <Text>{`${ParseFloat(pass/count).toFixed(2)}% tests passed`}</Text>
|
74
|
|
- </View>)
|
75
|
|
- }
|
76
|
|
-
|
77
|
92
|
if(Array.isArray(t.result) && !t.expired) {
|
78
|
93
|
t.result = t.result.map((r) => {
|
79
|
94
|
if(r.type.name === 'Assert' || r.type.name === 'Info') {
|
|
@@ -94,9 +109,9 @@ export default class Reporter extends Component {
|
94
|
109
|
t.status = 'waiting'
|
95
|
110
|
|
96
|
111
|
return (
|
97
|
|
- <TouchableOpacity onPress={()=>{
|
98
|
|
- t.start(t.sn)
|
99
|
|
- }}>
|
|
112
|
+ // <TouchableOpacity onPress={()=>{
|
|
113
|
+ // t.start(t.sn)
|
|
114
|
+ // }}>
|
100
|
115
|
<View key={'rn-test-' + t.desc} style={{
|
101
|
116
|
borderBottomWidth : 1.5,
|
102
|
117
|
borderColor : '#DDD',
|
|
@@ -111,8 +126,8 @@ export default class Reporter extends Component {
|
111
|
126
|
<View key={t.desc + '-result'} style={{backgroundColor : '#F4F4F4'}}>
|
112
|
127
|
{t.expand ? t.result : (t.status === 'pass' ? null : t.result)}
|
113
|
128
|
</View>
|
114
|
|
- </View>
|
115
|
|
- </TouchableOpacity>)
|
|
129
|
+ </View>)
|
|
130
|
+ {/*</TouchableOpacity>)*/}
|
116
|
131
|
}
|
117
|
132
|
|
118
|
133
|
updateDataSource() {
|