-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace withClickHandler with useClickHandler and add data-testid for easier testing.
- Loading branch information
1 parent
81642cf
commit 37822eb
Showing
2 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* SPDX-FileCopyrightText: 2025 Greenbone AG | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import {describe, test, testing} from '@gsa/testing'; | ||
import RowDetailsToggle from 'web/entities/Row'; | ||
import {fireEvent, rendererWith, screen, wait} from 'web/utils/Testing'; | ||
|
||
describe('RowDetailsToggle tests', () => { | ||
test('renders without crashing', () => { | ||
const {render} = rendererWith(); | ||
|
||
render(<RowDetailsToggle name="test" />); | ||
|
||
expect(screen.getByTestId('row-details-toggle')).toBeInTheDocument(); | ||
}); | ||
|
||
test('calls onClick handler when row is clicked', async () => { | ||
const handleClick = testing.fn(); | ||
const {render} = rendererWith(); | ||
|
||
render(<RowDetailsToggle name="test" onClick={handleClick} />); | ||
|
||
const row = screen.getByTestId('row-details-toggle'); | ||
fireEvent.click(row); | ||
expect(handleClick).toHaveBeenCalledWith(undefined, 'test'); | ||
}); | ||
}); |