Skip to content

Commit 88e15de

Browse files
committed
Render "No hooks found" upon finding no hooks
1 parent 9011d30 commit 88e15de

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/components/app/TestRunHooks.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.empty {
2+
font-style: italic;
3+
}
4+
15
.hooks {
26
padding: 0;
37
list-style: none;

src/components/app/TestRunHooks.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as messages from '@cucumber/messages'
22
import { Story } from '@ladle/react'
33
import React from 'react'
44

5+
import empty from '../../../acceptance/empty/empty.js'
56
import globalHooksAfterAllError from '../../../acceptance/global-hooks-afterall-error/global-hooks-afterall-error.js'
67
import globalHooksAttachments from '../../../acceptance/global-hooks-attachments/global-hooks-attachments.js'
78
import globalHooksBeforeAllError from '../../../acceptance/global-hooks-beforeall-error/global-hooks-beforeall-error.js'
@@ -16,6 +17,7 @@ const Template: Story<TemplateArgs> = ({ envelopes }) => {
1617
return (
1718
<EnvelopesProvider envelopes={envelopes}>
1819
<FilteredDocuments />
20+
<h2>BeforeAll/AfterAll</h2>
1921
<TestRunHooks />
2022
</EnvelopesProvider>
2123
)
@@ -25,6 +27,11 @@ export default {
2527
title: 'App/TestRunHooksList',
2628
}
2729

30+
export const EmptyGlobalHooks = Template.bind({})
31+
EmptyGlobalHooks.args = {
32+
envelopes: empty,
33+
}
34+
2835
export const GlobalHooksWithAttachments = Template.bind({})
2936
GlobalHooksWithAttachments.args = {
3037
envelopes: globalHooksAttachments,

src/components/app/TestRunHooks.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import styles from './TestRunHooks.module.scss'
77
export const TestRunHooks: FC = () => {
88
const hooks = useTestRunHooks()
99

10+
if (hooks.length === 0) {
11+
return <p className={styles.empty}>No hooks found.</p>
12+
}
13+
1014
return (
1115
<ol aria-label="RunHooks" className={styles.hooks}>
1216
{hooks.map(({ testRunHookFinished, hook }) => {

0 commit comments

Comments
 (0)