Skip to content

Commit 4c46610

Browse files
committed
add unit test
1 parent 317fe40 commit 4c46610

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

packages/module/src/MultiContentCard/MultiContentCard.test.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Ref } from 'react';
2-
import { screen, render } from '@testing-library/react';
2+
import { screen, render, act } from '@testing-library/react';
33
import { Button, Card, CardHeader, CardBody, Content, ContentVariants, Icon, List, ListItem, CardFooter, Dropdown, MenuToggle, DropdownList, DropdownItem, MenuToggleElement } from '@patternfly/react-core';
44
import { ArrowRightIcon, BellIcon, CogIcon, EllipsisVIcon, LockIcon } from '@patternfly/react-icons';
55
import MultiContentCard, { MultiContentCardDividerVariant } from './MultiContentCard';
@@ -126,6 +126,29 @@ describe('MultiContentCard component', () => {
126126
expect(container.firstChild).toMatchSnapshot();
127127
});
128128

129+
it('should call onExpand when expanding the multi-content card', () => {
130+
const onExpand = jest.fn();
131+
132+
render(
133+
<MultiContentCard
134+
isExpandable
135+
defaultExpanded={false}
136+
toggleText='Expandable card toggle text'
137+
cards={cards}
138+
onExpand={onExpand}
139+
/>
140+
);
141+
expect(screen.queryByText('Getting Started')).toBe(null);
142+
143+
act(() => {
144+
screen.getByRole('button', { name: 'Details' }).click();
145+
});
146+
147+
expect(onExpand).toHaveBeenCalled();
148+
149+
expect(screen.getByText('Getting Started')).toBeInTheDocument();
150+
});
151+
129152
it('should render expandable multi-content card - with actions', () => {
130153
const { container } = render(
131154
<MultiContentCard

0 commit comments

Comments
 (0)