Skip to content

Commit 00a21ef

Browse files
committed
chore: adds styled base container light/dark tests
1 parent 8991351 commit 00a21ef

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

packages/notifications/src/styled/StyledBase.spec.tsx

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,55 @@
66
*/
77

88
import React from 'react';
9-
import { render } from 'garden-test-utils';
9+
import { render, getRenderFn } from 'garden-test-utils';
1010
import { PALETTE } from '@zendeskgarden/react-theming';
1111
import { StyledBase } from './StyledBase';
12+
import { Type } from '../types';
1213

1314
describe('StyledBase', () => {
14-
it('should renders the correct background, border, and foreground color for a given type', () => {
15-
const { container } = render(<StyledBase $type="success" />);
15+
it.each<{ mode: 'light' | 'dark'; type: Type; color: string }>([
16+
{ mode: 'light', type: 'success', color: PALETTE.green[100] },
17+
{ mode: 'dark', type: 'success', color: PALETTE.green[1000] },
18+
{ mode: 'light', type: 'error', color: PALETTE.red[100] },
19+
{ mode: 'dark', type: 'error', color: PALETTE.red[1000] },
20+
{ mode: 'light', type: 'warning', color: PALETTE.yellow[100] },
21+
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[1000] },
22+
{ mode: 'light', type: 'info', color: PALETTE.grey[100] },
23+
{ mode: 'dark', type: 'info', color: PALETTE.grey[1000] }
24+
])('renders $mode mode $type background colors', ({ mode, type, color }) => {
25+
const { container } = getRenderFn(mode)(<StyledBase $type={type} />);
1626

17-
expect(container.firstChild).toHaveStyleRule('color', PALETTE.green[700]);
18-
expect(container.firstChild).toHaveStyleRule('border-color', PALETTE.green[300]);
19-
expect(container.firstChild).toHaveStyleRule('background-color', PALETTE.green[100]);
27+
expect(container.firstChild).toHaveStyleRule('background-color', color);
28+
});
29+
30+
it.each<{ mode: 'light' | 'dark'; type: Type; color: string }>([
31+
{ mode: 'light', type: 'success', color: PALETTE.green[300] },
32+
{ mode: 'dark', type: 'success', color: PALETTE.green[800] },
33+
{ mode: 'light', type: 'error', color: PALETTE.red[300] },
34+
{ mode: 'dark', type: 'error', color: PALETTE.red[800] },
35+
{ mode: 'light', type: 'warning', color: PALETTE.yellow[300] },
36+
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[800] },
37+
{ mode: 'light', type: 'info', color: PALETTE.grey[300] },
38+
{ mode: 'dark', type: 'info', color: PALETTE.grey[800] }
39+
])('renders $mode mode $type border colors', ({ mode, type, color }) => {
40+
const { container } = getRenderFn(mode)(<StyledBase $type={type} />);
41+
42+
expect(container.firstChild).toHaveStyleRule('border-color', color);
43+
});
44+
45+
it.each<{ mode: 'light' | 'dark'; type: Type; color: string }>([
46+
{ mode: 'light', type: 'success', color: PALETTE.green[700] },
47+
{ mode: 'dark', type: 'success', color: PALETTE.green[400] },
48+
{ mode: 'light', type: 'error', color: PALETTE.red[700] },
49+
{ mode: 'dark', type: 'error', color: PALETTE.red[400] },
50+
{ mode: 'light', type: 'warning', color: PALETTE.yellow[700] },
51+
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[400] },
52+
{ mode: 'light', type: 'info', color: PALETTE.grey[700] },
53+
{ mode: 'dark', type: 'info', color: PALETTE.grey[500] }
54+
])('renders $mode mode $type foreground colors', ({ mode, type, color }) => {
55+
const { container } = getRenderFn(mode)(<StyledBase $type={type} />);
56+
57+
expect(container.firstChild).toHaveStyleRule('color', color);
2058
});
2159

2260
it('renders neutral colors given no type', () => {

0 commit comments

Comments
 (0)