Skip to content

Commit 3d9bdd8

Browse files
test(AlertModal): add tests for default prop branches
Cover the onClose, footerNode, and isOverflowVisible default parameter branches, and the no-footer render path, to restore 100% coverage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent eb2ade8 commit 3d9bdd8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Modal/tests/AlertModal.test.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { render, screen } from '@testing-library/react';
3+
import userEvent from '@testing-library/user-event';
34

45
import { IntlProvider } from 'react-intl';
56
import AlertModal from '../AlertModal';
@@ -55,6 +56,29 @@ describe('<AlertModal />', () => {
5556
expect(body).toBeInTheDocument();
5657
});
5758

59+
it('renders without optional props', () => {
60+
render(
61+
<IntlProvider locale="en" messages={{}}>
62+
<AlertModal title="minimal" isOpen>
63+
<Body />
64+
</AlertModal>
65+
</IntlProvider>,
66+
);
67+
expect(screen.getByText('The body of alert.')).toBeInTheDocument();
68+
expect(screen.queryByText('footer')).not.toBeInTheDocument();
69+
});
70+
71+
it('calls default onClose when close button is clicked', async () => {
72+
render(
73+
<IntlProvider locale="en" messages={{}}>
74+
<AlertModal title="closeable" isOpen hasCloseButton>
75+
<Body />
76+
</AlertModal>
77+
</IntlProvider>,
78+
);
79+
await userEvent.click(screen.getByRole('button', { name: 'Close' }));
80+
});
81+
5882
describe('with variant prop', () => {
5983
it('renders warning variant', () => {
6084
render(

0 commit comments

Comments
 (0)