Skip to content

Commit

Permalink
fix: put summary in <Static>
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
SimenB committed Nov 14, 2019
1 parent 3864113 commit 5e2a427
Showing 1 changed file with 47 additions and 31 deletions.
78 changes: 47 additions & 31 deletions src/Reporter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,42 @@ const FailureMessage: React.FC<{
const CompletedTests: React.FC<{
completedTests: State['completedTests'];
globalConfig: Config.GlobalConfig;
}> = ({ completedTests, globalConfig }) => {
summary: React.ReactElement;
PostMessage: () => React.ReactElement;
done: boolean;
}> = ({ completedTests, globalConfig, summary, PostMessage, done }) => {
if (completedTests.length === 0) {
return null;
}
const didUpdate = globalConfig.updateSnapshot === 'all';

let testOutputs = completedTests.map(({ testResult, config }) => (
<React.Fragment key={testResult.testFilePath + config.name}>
<ResultHeader config={config} testResult={testResult} />
<TestConsoleOutput
console={testResult.console}
verbose={globalConfig.verbose}
cwd={config.cwd}
/>
<FailureMessage failureMessage={testResult.failureMessage} />
<SnapshotStatus snapshot={testResult.snapshot} afterUpdate={didUpdate} />
</React.Fragment>
));

if (done) {
testOutputs = testOutputs.concat(
<Box paddingTop={1} key="summary">
{summary}
</Box>,
<React.Fragment key="postmessage">
<PostMessage />
</React.Fragment>,
);
}

return (
<Box paddingBottom={1} flexDirection="column">
<Static>
{completedTests.map(({ testResult, config }) => (
<React.Fragment key={testResult.testFilePath + config.name}>
<ResultHeader config={config} testResult={testResult} />
<TestConsoleOutput
console={testResult.console}
verbose={globalConfig.verbose}
cwd={config.cwd}
/>
<FailureMessage failureMessage={testResult.failureMessage} />
<SnapshotStatus
snapshot={testResult.snapshot}
afterUpdate={didUpdate}
/>
</React.Fragment>
))}
</Static>
<Static>{testOutputs}</Static>
</Box>
);
};
Expand Down Expand Up @@ -236,29 +247,34 @@ const Reporter: React.FC<Props> = ({
const { exit } = useApp();
React.useEffect(() => {
if (done) {
exit();
setImmediate(exit);
}
}, [done, exit]);

const summary = (
<Summary
aggregatedResults={aggregatedResults}
options={{ estimatedTime, roundTime: true, width }}
done={done}
/>
);
return (
<Box flexDirection="column">
<CompletedTests
completedTests={completedTests}
globalConfig={globalConfig}
/>
<RunningTests tests={currentTests} width={width} />
<Summary
aggregatedResults={aggregatedResults}
options={{ estimatedTime, roundTime: true, width }}
summary={summary}
done={done}
PostMessage={() => (
<PostMessage
aggregatedResults={aggregatedResults}
globalConfig={globalConfig}
contexts={contexts}
/>
)}
/>
{done ? (
<PostMessage
aggregatedResults={aggregatedResults}
globalConfig={globalConfig}
contexts={contexts}
/>
) : null}
<RunningTests tests={currentTests} width={width} />
{done ? null : summary}
</Box>
);
};
Expand Down

0 comments on commit 5e2a427

Please sign in to comment.