-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathUnitTestScreen.tsx
More file actions
51 lines (45 loc) · 1.18 KB
/
UnitTestScreen.tsx
File metadata and controls
51 lines (45 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { useEffect, useState } from 'react'
import { FlatList, StyleSheet, Text } from 'react-native'
import type { MochaTestResult } from '../tests/MochaSetup'
import { runTests } from '../tests/MochaSetup'
import {
registerUnitTests,
/* registerTypeORMUnitTests, */
} from '../tests/unit'
export function UnitTestScreen() {
const [results, setResults] = useState<MochaTestResult[]>([])
useEffect(() => {
setResults([])
runTests(
registerUnitTests,
// registerTypeORMUnitTests
).then(setResults)
}, [])
return (
<FlatList
style={styles.unitTestsScreenContainer}
contentContainerStyle={styles.contentContainer}
data={results}
renderItem={({ item }) => {
if (item.type === 'grouping') return <Text>{item.description}</Text>
if (item.type === 'incorrect') {
return (
<Text>
🔴 {item.description}: {item.errorMsg}
</Text>
)
}
return <Text>🟢 {item.description}</Text>
}}
/>
)
}
const styles = StyleSheet.create({
unitTestsScreenContainer: {
flex: 1,
},
contentContainer: {
padding: 20,
paddingBottom: 50,
},
})