Skip to content

Commit c2a4ab9

Browse files
committed
test: Improve test coverage, remove default icon
1 parent 6cc08c5 commit c2a4ab9

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

src/action-card/__tests__/action-card.test.tsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,71 @@ describe('ActionCard Component', () => {
249249
expect(wrapper.getElement()).not.toHaveAttribute('aria-labelledby');
250250
});
251251
});
252+
253+
describe('variant', () => {
254+
test('renders with embedded variant', () => {
255+
const wrapper = renderActionCard({ variant: 'embedded', header: 'Header' });
256+
expect(wrapper.getElement()).toBeTruthy();
257+
});
258+
});
259+
260+
describe('iconVerticalAlignment', () => {
261+
test('places icon in header row when alignment is top and header is present', () => {
262+
const wrapper = renderActionCard({ icon: <span>icon</span>, iconVerticalAlignment: 'top', header: 'Header' });
263+
expect(wrapper.findIcon()).not.toBeNull();
264+
expect(wrapper.findHeader()).not.toBeNull();
265+
});
266+
267+
test('places icon outside header row when alignment is center', () => {
268+
const wrapper = renderActionCard({
269+
icon: <span>icon</span>,
270+
iconVerticalAlignment: 'center',
271+
header: 'Header',
272+
});
273+
expect(wrapper.findIcon()).not.toBeNull();
274+
expect(wrapper.findHeader()).not.toBeNull();
275+
});
276+
277+
test('places icon outside header row when there is no header', () => {
278+
const wrapper = renderActionCard({ icon: <span>icon</span>, iconVerticalAlignment: 'top' });
279+
expect(wrapper.findIcon()).not.toBeNull();
280+
expect(wrapper.findHeader()).toBeNull();
281+
});
282+
});
283+
284+
describe('padding options', () => {
285+
test('renders with disableHeaderPaddings', () => {
286+
const wrapper = renderActionCard({ header: 'Header', disableHeaderPaddings: true });
287+
expect(wrapper.findHeader()!.getElement()).toHaveTextContent('Header');
288+
});
289+
290+
test('renders with disableContentPaddings', () => {
291+
const wrapper = renderActionCard({ children: 'Content', disableContentPaddings: true });
292+
expect(wrapper.findContent()!.getElement()).toHaveTextContent('Content');
293+
});
294+
});
295+
296+
describe('description with header', () => {
297+
test('renders both header and description together', () => {
298+
const wrapper = renderActionCard({ header: 'Header', description: 'Description' });
299+
expect(wrapper.findHeader()!.getElement()).toHaveTextContent('Header');
300+
expect(wrapper.findDescription()!.getElement()).toHaveTextContent('Description');
301+
});
302+
});
303+
304+
describe('disabled styling', () => {
305+
test('applies disabled styling to header and description', () => {
306+
const wrapper = renderActionCard({ header: 'Header', description: 'Description', disabled: true });
307+
expect(wrapper.findHeader()).not.toBeNull();
308+
expect(wrapper.findDescription()).not.toBeNull();
309+
expect(wrapper.isDisabled()).toBe(true);
310+
});
311+
});
312+
313+
describe('no icon', () => {
314+
test('renders no icon when icon prop is not specified', () => {
315+
const wrapper = renderActionCard({ header: 'Header' });
316+
expect(wrapper.findIcon()).toBeNull();
317+
});
318+
});
252319
});

src/action-card/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
'use client';
44
import React from 'react';
55

6-
import InternalIcon from '../icon/internal';
76
import useBaseComponent from '../internal/hooks/use-base-component';
87
import { applyDisplayName } from '../internal/utils/apply-display-name';
98
import { getExternalProps } from '../internal/utils/external-props';
@@ -20,7 +19,6 @@ const ActionCard = React.forwardRef(
2019
disableContentPaddings = false,
2120
iconVerticalAlignment = 'top',
2221
variant = 'default',
23-
icon = <InternalIcon name="angle-right" />,
2422
...props
2523
}: ActionCardProps,
2624
ref: React.Ref<ActionCardProps.Ref>
@@ -45,7 +43,6 @@ const ActionCard = React.forwardRef(
4543
disableContentPaddings={disableContentPaddings}
4644
iconVerticalAlignment={iconVerticalAlignment}
4745
variant={variant}
48-
icon={icon}
4946
{...externalProps}
5047
{...baseComponentProps}
5148
/>

0 commit comments

Comments
 (0)