0b7bb7e55d11449a860b41d9ed8f61dd538611d3.svn-base
1.74 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
52
53
54
55
56
57
58
59
60
61
62
63
const React = require('react')
const {Box, Color} = require('ink')
const prettyDiff = require('../../pretty-diff.js')
const prettySource = require('../../pretty-source.js')
const yaml = require('tap-yaml')
const importJSX = require('import-jsx')
const PassFail = importJSX('./pass-fail.js')
const AssertName = importJSX('./assert-name.js')
module.exports = ({res}) => {
const {ok, id, name, testName, skip, todo} = res
const diag = res.diag || {}
const diff = prettyDiff(diag && diag.diff)
if (diff) {
delete diag.diff
delete diag.found
delete diag.wanted
delete diag.pattern
delete diag.compare
}
const source = prettySource(diag)
if (source)
delete diag.source
// pretty-print errors found in t.error() assertions
const origin = diag && diag.found && diag.origin
const originSrc = prettySource(origin)
if (originSrc) {
origin.message = diag.found.message
delete diag.origin
delete diag.found
delete origin.source
}
delete diag.didNotWant
return (
<Box flexDirection="column">
<PassFail ok={ok} name={testName} skip={skip} todo={todo} />
<AssertName {...{ok, name, skip, todo}} />
{' '}
{ source ? (<Box>{source}</Box>) : '' }
{ diff ? (<Box>{ diff + '\n'}</Box>) : '' }
{ diag && Object.keys(diag).length ? (
<Box>
{` ${
yaml.stringify({
test: res.fullname,
...diag,
}).split('\n').join('\n ')
}`}
</Box>
) : '' }
{ originSrc ? (
<Box flexDirection="column">
<Box marginLeft={2}>Error Origin:{'\n'}</Box>
<Box>{originSrc}</Box>
<Box marginLeft={2}>{yaml.stringify(origin)}</Box>
</Box>
) : '' }
</Box>
)
}