512336976590929982cadb2619d1b4b41062419a.svn-base
962 Bytes
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
const React = require('react')
const {Box, Color} = require('ink')
const glyphColor = ({ ok, skip, todo }) => ({
[ skip ? 'cyan'
: todo ? 'magenta'
: !ok ? 'red'
: 'green']: true,
})
const glyphText = ({ ok, skip, todo }) =>
skip ? ' ~ '
: todo ? ' ☐ '
: !ok ? ' ✖ '
: ' ✓ '
const Glyph = ({ ok, skip, todo }) => (
<Box width={3}>
<Color bold {...glyphColor({ok, skip, todo})}>
{glyphText({ok, skip, todo})}
</Color>
</Box>
)
const Reason = ({skip, todo}) =>
skip && skip !== true ? (
<Box>
{' > '}
<Color {...glyphColor({skip, todo})}>{skip}</Color>
</Box>
)
: todo && todo !== true ? (
<Box>
{' > '}
<Color {...glyphColor({skip, todo})}>{todo}</Color>
</Box>
)
: ''
const AssertName = ({ ok, name, skip, todo }) => (
<Box>
<Glyph {...{ok, skip, todo}} />
{name || '(unnamed test)'}
<Reason {...{skip, todo}} />
</Box>
)
module.exports = AssertName