@@ -6,58 +6,70 @@ import { useNavigation } from '@react-navigation/native';
66import { colors } from '../styles/colors' ;
77
88type TestItemProps = {
9- suiteIndex : number ;
9+ suiteIndex ? : number ;
1010 description : string ;
11- value : boolean ;
11+ value ? : boolean ;
1212 count : number ;
13- results : TestResult [ ] ;
14- onToggle : ( description : string ) => void ;
13+ results ?: TestResult [ ] ;
14+ onToggle ?: ( description : string ) => void ;
15+ isFooter ?: boolean ;
16+ passCount ?: number ;
17+ failCount ?: number ;
1518} ;
1619
1720export const TestItem : React . FC < TestItemProps > = ( {
18- suiteIndex,
21+ suiteIndex = 0 ,
1922 description,
20- value,
23+ value = false ,
2124 count,
22- results,
25+ results = [ ] ,
2326 onToggle,
27+ isFooter = false ,
28+ passCount,
29+ failCount,
2430} : TestItemProps ) => {
2531 const navigation = useNavigation ( ) ;
2632
2733 // get pass/fail stats from results
28- let pass = 0 ;
29- let fail = 0 ;
30- results . map ( r => {
31- if ( r . type === 'correct' ) {
32- pass ++ ;
33- }
34- if ( r . type === 'incorrect' ) {
35- fail ++ ;
36- }
37- } ) ;
34+ let pass = passCount ?? 0 ;
35+ let fail = failCount ?? 0 ;
36+
37+ if ( ! isFooter ) {
38+ results . map ( r => {
39+ if ( r . type === 'correct' ) {
40+ pass ++ ;
41+ }
42+ if ( r . type === 'incorrect' ) {
43+ fail ++ ;
44+ }
45+ } ) ;
46+ }
3847
3948 return (
40- < View
41- style = { styles . container }
42- testID = { `test-suite-${ description . replace ( / \s + / g, '-' ) . toLowerCase ( ) } ` }
43- >
44- < BouncyCheckbox
45- isChecked = { value }
46- onPress = { ( ) => {
47- onToggle ( description ) ;
48- } }
49- fillColor = { colors . blue }
50- style = { styles . checkbox }
51- disableBuiltInState = { true }
52- />
49+ < View style = { styles . container } >
50+ { isFooter ? (
51+ < Text style = { styles . timer } > ⏱️</ Text >
52+ ) : (
53+ < BouncyCheckbox
54+ isChecked = { value }
55+ onPress = { ( ) => {
56+ onToggle ?.( description ) ;
57+ } }
58+ fillColor = { colors . blue }
59+ style = { styles . checkbox }
60+ disableBuiltInState = { true }
61+ />
62+ ) }
5363 < TouchableOpacity
5464 style = { styles . touchable }
5565 onPress = { ( ) => {
56- // @ts -expect-error - not dealing with navigation types rn
57- navigation . navigate ( 'TestDetailsScreen' , {
58- results,
59- suiteName : description ,
60- } ) ;
66+ if ( ! isFooter ) {
67+ // @ts -expect-error - not dealing with navigation types rn
68+ navigation . navigate ( 'TestDetailsScreen' , {
69+ results,
70+ suiteName : description ,
71+ } ) ;
72+ }
6173 } }
6274 >
6375 < Text
@@ -70,21 +82,33 @@ export const TestItem: React.FC<TestItemProps> = ({
7082 < Text
7183 style = { [ styles . pass , styles . count ] }
7284 numberOfLines = { 1 }
73- testID = { `test-suite-${ suiteIndex } -pass-count` }
85+ testID = {
86+ isFooter
87+ ? 'completion-stats'
88+ : `test-suite-${ suiteIndex } -pass-count`
89+ }
7490 >
75- { pass || '' }
91+ { isFooter ? pass : pass || '' }
7692 </ Text >
7793 < Text
7894 style = { [ styles . fail , styles . count ] }
7995 numberOfLines = { 1 }
80- testID = { `test-suite-${ suiteIndex } -fail-count` }
96+ testID = {
97+ isFooter
98+ ? 'total-fail-count'
99+ : `test-suite-${ suiteIndex } -fail-count`
100+ }
81101 >
82- { fail || '' }
102+ { isFooter ? fail : fail || '' }
83103 </ Text >
84104 < Text
85105 style = { styles . count }
86106 numberOfLines = { 1 }
87- testID = { `test-suite-${ suiteIndex } -total-count` }
107+ testID = {
108+ isFooter
109+ ? 'total-test-count'
110+ : `test-suite-${ suiteIndex } -total-count`
111+ }
88112 >
89113 { count }
90114 </ Text >
@@ -104,12 +128,13 @@ const styles = StyleSheet.create({
104128 borderBottomWidth : 1 ,
105129 borderBottomColor : colors . gray ,
106130 paddingHorizontal : 10 ,
131+ marginVertical : - 1 ,
107132 } ,
108133 checkbox : {
109- transform : [ { scaleX : 0.7 } , { scaleY : 0.7 } ] ,
134+ transform : [ { scaleX : 0.6 } , { scaleY : 0.6 } ] ,
110135 } ,
111136 label : {
112- fontSize : 12 ,
137+ fontSize : 11 ,
113138 flex : 8 ,
114139 } ,
115140 touchable : {
@@ -126,5 +151,11 @@ const styles = StyleSheet.create({
126151 fontSize : 11 ,
127152 flex : 1 ,
128153 textAlign : 'right' ,
154+ paddingHorizontal : 1 ,
155+ } ,
156+ timer : {
157+ fontSize : 14 ,
158+ paddingHorizontal : 6 ,
159+ paddingVertical : 4 ,
129160 } ,
130161} ) ;
0 commit comments