Skip to content

Commit

Permalink
fix: use padding for spacing rather than spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Nov 13, 2019
1 parent 815430d commit c98de61
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions src/PostMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,39 @@ import { testPathPatternToRegExp } from 'jest-util';
import * as React from 'react';
import { Box, Color, Text } from 'ink';

const LeftPadded: React.FC = ({ children }) => (
<Box paddingLeft={1}>{children}</Box>
);

const HorizontallyPadded: React.FC = ({ children }) => (
<Box paddingX={1}>{children}</Box>
);

const TestInfo: React.FC<{ config: Config.GlobalConfig }> = ({ config }) => {
if (config.runTestsByPath) {
return <Color dim> within paths</Color>;
return (
<LeftPadded>
<Color dim>within paths</Color>
</LeftPadded>
);
}

if (config.onlyChanged) {
return <Color dim> related to changed files</Color>;
return (
<LeftPadded>
<Color dim>related to changed files</Color>
</LeftPadded>
);
}

if (config.testPathPattern) {
const prefix = config.findRelatedTests
? ' related to files matching '
: ' matching ';
? 'related to files matching'
: 'matching';

return (
<Box>
<Color dim>{prefix}</Color>
<HorizontallyPadded>{prefix}</HorizontallyPadded>
<Text>
{testPathPatternToRegExp(config.testPathPattern).toString()}
</Text>
Expand All @@ -39,10 +55,11 @@ const NameInfo: React.FC<{ config: Config.GlobalConfig }> = ({ config }) => {

if (config.testNamePattern) {
return (
<Color dim>
{' '}
with tests matching &quot;{config.testNamePattern}&quot;
</Color>
<LeftPadded>
<Color dim>
with tests matching &quot;{config.testNamePattern}&quot;
</Color>
</LeftPadded>
);
}

Expand All @@ -55,7 +72,9 @@ const ContextInfo: React.FC<{ numberOfContexts: number }> = ({
if (numberOfContexts > 1) {
return (
<>
<Color dim> in </Color>
<HorizontallyPadded>
<Color dim>in</Color>
</HorizontallyPadded>
<Text>{numberOfContexts}</Text>
<Color dim> projects</Color>
</>
Expand Down

0 comments on commit c98de61

Please sign in to comment.