Skip to content

Commit e6783b1

Browse files
test: add a test for componentDidMount first TDD
1 parent 049df79 commit e6783b1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const Component = props => {
2121
useOnDependenciesChange
2222
} = useLifecycleHelpers(state, props)
2323

24+
useComponentDidMount(() => {
25+
setComponentState('Mounted')
26+
})
27+
2428
return (
2529
<div id='component'>
2630
<p>{componentState}</p>
@@ -38,4 +42,9 @@ function renderComponent(props) {
3842
}
3943

4044
describe('Test useLifecycleHelpers custom hook', () => {
45+
test('The component should be mounted', () => {
46+
const { getByText } = renderComponent()
47+
48+
getByText(/Mounted/i)
49+
})
4150
})

0 commit comments

Comments
 (0)