diff --git a/packages/react-core/src/components/Alert/__tests__/AlertGroup.test.tsx b/packages/react-core/src/components/Alert/__tests__/AlertGroup.test.tsx index deee28f7748..a2d6186f28d 100644 --- a/packages/react-core/src/components/Alert/__tests__/AlertGroup.test.tsx +++ b/packages/react-core/src/components/Alert/__tests__/AlertGroup.test.tsx @@ -7,77 +7,81 @@ import { Alert } from '../../Alert'; import { AlertGroup } from '../../Alert'; import { AlertActionCloseButton } from '../../../components/Alert/AlertActionCloseButton'; -describe('AlertGroup', () => { - test('Alert Group renders without children', () => { - const { asFragment } = render(); - expect(asFragment()).toMatchSnapshot(); - }); - - test('Alert Group works with n children', () => { - const { asFragment } = render( - - - - - ); - expect(asFragment()).toBeTruthy(); - }); - - test('Alert group overflow shows up', async () => { - const overflowMessage = 'View 2 more alerts'; - const onOverflowClick = jest.fn(); - const user = userEvent.setup(); - - render( - - - - ); - - expect(screen.getAllByRole('listitem')).toHaveLength(2); - - const overflowButton = screen.getByRole('button', { name: 'View 2 more alerts' }); - expect(overflowButton).toBeInTheDocument(); - - await user.click(overflowButton); - expect(onOverflowClick).toHaveBeenCalled(); - }); - - test('Standard Alert Group is not a toast alert group', () => { - render( - - - - ); - - expect(screen.getByText('alert title').parentElement).not.toHaveClass('pf-m-toast'); - }); - - test('Toast Alert Group contains expected modifier class', () => { - render( - - - - ); - - expect(screen.getByLabelText('group label')).toHaveClass('pf-m-toast'); - }); - - test('alertgroup closes when alerts are closed', async () => { - const onClose = jest.fn(); - const user = userEvent.setup(); - - render( - - } - /> - - ); - - await user.click(screen.getByLabelText('Close')); - expect(onClose).toHaveBeenCalled(); - }); +test('Alert Group renders without children', () => { + render( +
+ +
+ ); + + expect(screen.getByTestId('container').firstChild).toBeVisible(); + expect(screen.getByTestId('alertgroup').children.length).toBe(0); +}); + +test('Alert Group works with n children', () => { + const { asFragment } = render( + + + + + ); + expect(screen.getByTestId('container').children.length).toBe(2); +}); + +test('Alert group overflow shows up', async () => { + const overflowMessage = 'View 2 more alerts'; + const onOverflowClick = jest.fn(); + const user = userEvent.setup(); + + render( + + + + ); + + expect(screen.getAllByRole('listitem')).toHaveLength(2); + + const overflowButton = screen.getByRole('button', { name: 'View 2 more alerts' }); + expect(overflowButton).toBeInTheDocument(); + + await user.click(overflowButton); + expect(onOverflowClick).toHaveBeenCalled(); +}); + +test('Standard Alert Group is not a toast alert group', () => { + render( + + + + ); + + expect(screen.getByText('alert title').parentElement).not.toHaveClass('pf-m-toast'); +}); + +test('Toast Alert Group contains expected modifier class', () => { + render( + + + + ); + + expect(screen.getByLabelText('group label')).toHaveClass('pf-m-toast'); +}); + +test('alertgroup closes when alerts are closed', async () => { + const onClose = jest.fn(); + const user = userEvent.setup(); + + render( + + } + /> + + ); + + await user.click(screen.getByLabelText('Close')); + expect(onClose).toHaveBeenCalled(); }); diff --git a/packages/react-core/src/components/Alert/__tests__/__snapshots__/AlertGroup.test.tsx.snap b/packages/react-core/src/components/Alert/__tests__/__snapshots__/AlertGroup.test.tsx.snap deleted file mode 100644 index bdbd0152e6e..00000000000 --- a/packages/react-core/src/components/Alert/__tests__/__snapshots__/AlertGroup.test.tsx.snap +++ /dev/null @@ -1,10 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AlertGroup Alert Group renders without children 1`] = ` - -