Skip to content

Commit 71c12e1

Browse files
committed
add tests
1 parent 25fbe01 commit 71c12e1

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

packages/react/src/Card/Card.test.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,32 @@ describe('Card', () => {
8080
expect(cardEl.classList).toContain('Card--variant-minimal')
8181
})
8282

83+
it('defaults to the default background color for the default variant', () => {
84+
const mockTestId = 'test'
85+
86+
const {getByTestId} = render(
87+
<Card href={mockHref} data-testid={mockTestId}>
88+
<Card.Heading>{mockHeading}</Card.Heading>
89+
</Card>,
90+
)
91+
92+
const cardEl = getByTestId(mockTestId)
93+
expect(cardEl.classList).toContain('Card--backgroundColor-default')
94+
})
95+
96+
it('defaults to a transparent background for the minimal variant', () => {
97+
const mockTestId = 'test'
98+
99+
const {getByTestId} = render(
100+
<Card variant="minimal" href={mockHref} data-testid={mockTestId}>
101+
<Card.Heading>{mockHeading}</Card.Heading>
102+
</Card>,
103+
)
104+
105+
const cardEl = getByTestId(mockTestId)
106+
expect(cardEl.classList).toContain('Card--backgroundColor-none')
107+
})
108+
83109
it('renders a default variant in dark mode', () => {
84110
const mockTestId = 'test'
85111

packages/react/src/Card/Card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ const CardRoot = forwardRef<HTMLDivElement, CardProps>(
110110
className,
111111
ctaText = 'Learn more',
112112
ctaVariant = defaultCardCTAVariant,
113-
backgroundColor = 'default',
114113
disableAnimation = false,
115114
fullWidth = false,
116115
href,
117116
hasBorder = false,
118117
leadingVisual,
119118
style,
120119
variant = 'default',
120+
backgroundColor = variant === 'minimal' ? 'none' : 'default',
121121
...props
122122
},
123123
ref,

0 commit comments

Comments
 (0)