Skip to content

Commit 6a33c81

Browse files
committed
fix: use normal spaces as padding instead of nbsp
1 parent aa29f45 commit 6a33c81

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"@jest/reporters": "^25.0.0",
100100
"@jest/test-result": "^25.0.0",
101101
"@jest/types": "^25.0.0",
102+
"chalk": "^2.4.2",
102103
"ink": "^2.5.0",
103104
"jest-util": "^25.0.0",
104105
"react": "^16.11.0",

src/shared.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,36 @@ import * as React from 'react';
22
import { Box, Color, ColorProps } from 'ink';
33
import { TestResult } from '@jest/test-result';
44
import { Config } from '@jest/types';
5+
import chalk from 'chalk';
56
import slash from 'slash';
67
import { relativePath } from './utils';
78

89
export const Arrow: React.FC = () => <>{' \u203A '}</>;
910
export const Dot: React.FC = () => <>{' \u2022 '}</>;
1011
export const DownArrow: React.FC = () => <>{' \u21B3 '}</>;
1112

13+
const pad = (string: string) => (chalk.supportsColor ? ` ${string} ` : string);
14+
1215
const PaddedColor: React.FC<ColorProps> = ({ children, ...props }) => (
1316
<Box paddingRight={1}>
14-
<Color {...props}>
15-
&nbsp;
16-
{children}
17-
&nbsp;
18-
</Color>
17+
<Color {...props}>{children}</Color>
1918
</Box>
2019
);
2120

22-
const Status: React.FC<ColorProps> = props => (
23-
<PaddedColor inverse bold {...props} />
21+
const Status: React.FC<ColorProps & { text: string }> = ({
22+
text,
23+
...props
24+
}) => (
25+
<PaddedColor inverse bold {...props}>
26+
{pad(text)}
27+
</PaddedColor>
2428
);
2529

26-
const Fails: React.FC = () => <Status red>FAIL</Status>;
30+
const Fails: React.FC = () => <Status red text="FAIL" />;
2731

28-
const Pass: React.FC = () => <Status green>PASS</Status>;
32+
const Pass: React.FC = () => <Status green text="PASS" />;
2933

30-
export const Runs: React.FC = () => <Status yellow>RUNS</Status>;
34+
export const Runs: React.FC = () => <Status yellow text="RUNS" />;
3135

3236
export const DisplayName: React.FC<{
3337
config: Config.ProjectConfig;

0 commit comments

Comments
 (0)