From 636edb827457ef2385f8e5a564ba910462ce3f64 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 13 Nov 2019 15:28:22 +0100 Subject: [PATCH] fix: always pass column width --- src/Reporter.tsx | 52 ++++++++++++++++++++++++++++-------------------- src/shared.tsx | 9 +++++---- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/Reporter.tsx b/src/Reporter.tsx index 961168e..5051ccc 100644 --- a/src/Reporter.tsx +++ b/src/Reporter.tsx @@ -70,11 +70,8 @@ const TestConsoleOutput = ({ }; const CompletedTests: React.FC<{ - completedTests: Array<{ - testResult: TestResult; - config: Config.ProjectConfig; - }>; - width?: number; + completedTests: State['completedTests']; + width: number; globalConfig: Config.GlobalConfig; }> = ({ completedTests, width, globalConfig }) => { if (completedTests.length === 0) { @@ -86,7 +83,7 @@ const CompletedTests: React.FC<{ {completedTests.map(({ testResult, config }) => ( - + = ( } }; +const RunningTests: React.FC<{ + tests: State['currentTests']; + width: number; +}> = ({ tests, width }) => { + if (tests.length === 0) { + return null; + } + + return ( + + {tests.map(([path, config]) => ( + + + + + + ))} + + ); +}; + const Reporter: React.FC = ({ register, globalConfig, @@ -220,22 +243,7 @@ const Reporter: React.FC = ({ width={width} globalConfig={globalConfig} /> - {currentTests.length > 0 && ( - - {currentTests.map(([path, config]) => ( - - - - - - ))} - - )} + = ({ testResult }) => { export const ResultHeader: React.FC<{ testResult: TestResult; config: Config.ProjectConfig; - width?: number; + width: number; }> = ({ testResult, config, width }) => ( @@ -92,9 +92,9 @@ export const FormattedPath = ({ pad: number; config: Config.ProjectConfig | Config.GlobalConfig; testPath: Config.Path; - columns?: number; + columns: number; }) => { - const maxLength = (columns || 0) - pad; + const maxLength = columns - pad; const relative = relativePath(config, testPath); const { basename } = relative; let { dirname } = relative; @@ -147,5 +147,6 @@ export const FormatFullTestPath: React.FC<{ config: Config.GlobalConfig | Config.ProjectConfig; testPath: Config.Path; }> = ({ config, testPath }) => ( - + // TODO: maybe not 9000? We just don't want to trim it + );