rozetko
2 years ago
3 changed files with 1 additions and 43 deletions
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<testsuites name="jest tests" tests="3" failures="0" errors="0" time="2.424"> |
||||
<testsuite name="RemoveCurrentConfigurationButton" errors="0" failures="0" skipped="0" timestamp="2022-12-19T18:00:28" time="1.512" tests="3"> |
||||
<testcase classname="RemoveCurrentConfigurationButton It renders properly when enabled" name="RemoveCurrentConfigurationButton It renders properly when enabled" time="0.022"> |
||||
</testcase> |
||||
<testcase classname="RemoveCurrentConfigurationButton It renders properly when disabled" name="RemoveCurrentConfigurationButton It renders properly when disabled" time="0.003"> |
||||
</testcase> |
||||
<testcase classname="RemoveCurrentConfigurationButton It calls the onClick handler when clicked" name="RemoveCurrentConfigurationButton It calls the onClick handler when clicked" time="0.164"> |
||||
</testcase> |
||||
</testsuite> |
||||
</testsuites> |
@ -1,32 +0,0 @@
|
||||
import React from 'react'; |
||||
|
||||
import { render, screen } from '@testing-library/react'; |
||||
import userEvent from '@testing-library/user-event'; |
||||
|
||||
import RemoveCurrentConfigurationButton from '.'; |
||||
|
||||
describe('RemoveCurrentConfigurationButton', () => { |
||||
test('It renders properly when enabled', () => { |
||||
const component = render(<RemoveCurrentConfigurationButton onClick={() => {}} disabled={false} />); |
||||
expect(component.baseElement).toMatchSnapshot(); |
||||
}); |
||||
|
||||
test('It renders properly when disabled', () => { |
||||
const component = render(<RemoveCurrentConfigurationButton onClick={() => {}} disabled />); |
||||
expect(component.baseElement).toMatchSnapshot(); |
||||
}); |
||||
|
||||
test('It calls the onClick handler when clicked', async () => { |
||||
const mockedOnClick = jest.fn(); |
||||
|
||||
render(<RemoveCurrentConfigurationButton onClick={mockedOnClick} disabled={false} />); |
||||
|
||||
// click the button, which opens the modal
|
||||
await userEvent.click(screen.getByRole('button')); |
||||
// click the confirm button within the modal, which actually triggers the callback
|
||||
await userEvent.click(screen.getByText('Remove')); |
||||
|
||||
expect(mockedOnClick).toHaveBeenCalledWith(); |
||||
expect(mockedOnClick).toHaveBeenCalledTimes(1); |
||||
}); |
||||
}); |
Loading…
Reference in new issue