-
-
Notifications
You must be signed in to change notification settings - Fork 269
/
suite-summary.tsx
87 lines (80 loc) · 2.57 KB
/
suite-summary.tsx
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { CountsJSON, TestBase } from '@tapjs/core'
import { Box, Text } from 'ink'
import React, { FC } from 'react'
import { BailedOut } from './bailed-out.js'
import { useAssertTotals } from './hooks/use-assert-totals.js'
import { useComments } from './hooks/use-comments.js'
import { useSuiteTotals } from './hooks/use-suite-totals.js'
import { TimedOut } from './timed-out.js'
const Complete: FC<CountsJSON> = ({ pass, fail = 0, total }) => (
<Text bold dimColor>
{pass + fail} of {total} complete
</Text>
)
const Skip: FC<CountsJSON> = ({ skip = 0 }) => (
<Text color="cyan">{skip} skip</Text>
)
const Fail: FC<CountsJSON> = ({ fail = 0 }) => (
<Text color="red" dimColor={fail === 0} bold={fail !== 0}>
{fail} fail
</Text>
)
const Pass: FC<CountsJSON> = ({ pass }) => (
<Text color="green">{pass} pass</Text>
)
const Todo: FC<CountsJSON> = ({ todo = 0 }) =>
todo ?
<Box flexDirection="column" alignItems="flex-end">
<Text color="magenta">{todo} todo</Text>
<Text> </Text>
</Box>
: <></>
export const SuiteSummary: FC<{ test: TestBase }> = ({ test }) => {
const suites = useSuiteTotals(test)
const asserts = useAssertTotals(test)
const comments = useComments(test)
return (
<Box flexDirection="column">
<Box marginY={1} flexDirection="column">
<Box>
<Box flexDirection="row" gap={2} alignSelf="flex-end">
<Box flexDirection="column">
<Text bold>Asserts:</Text>
<Text bold>Suites:</Text>
</Box>
<Box flexDirection="column" alignItems="flex-end">
<Pass {...asserts} />
<Pass {...suites} />
</Box>
<Box flexDirection="column" alignItems="flex-end">
<Fail {...asserts} />
<Fail {...suites} />
</Box>
{(!!suites.skip || !!asserts.skip) && (
<Box flexDirection="column" alignItems="flex-end">
<Skip {...asserts} />
<Skip {...suites} />
</Box>
)}
<Todo {...asserts} />
<Box flexDirection="column" alignItems="flex-end">
<Complete {...asserts} />
<Complete {...suites} />
</Box>
</Box>
</Box>
<BailedOut test={test} />
<TimedOut test={test} />
</Box>
{comments.length ?
<Box flexDirection="column" marginBottom={1}>
{comments.map((c, key) => (
<Text key={key} dimColor>
{c}
</Text>
))}
</Box>
: <></>}
</Box>
)
}