|
7 | 7 |
|
8 | 8 | import React from 'react'; |
9 | 9 | import { css } from 'styled-components'; |
10 | | -import { DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming'; |
11 | | -import { render } from 'garden-test-utils'; |
| 10 | +import { PALETTE } from '@zendeskgarden/react-theming'; |
| 11 | +import { getRenderFn } from 'garden-test-utils'; |
12 | 12 | import { StyledAlert, StyledTitle } from '../styled'; |
13 | 13 | import { Type } from '../types'; |
14 | 14 |
|
15 | 15 | describe('StyledAlert', () => { |
16 | | - it(`should render the styling correctly for a Notification's title`, () => { |
17 | | - const validationHues: Record<Type, string> = { |
18 | | - success: 'successHue', |
19 | | - error: 'dangerHue', |
20 | | - warning: 'warningHue', |
21 | | - info: 'neutralHue' |
22 | | - }; |
| 16 | + it.each<{ mode: 'light' | 'dark'; type: Type; color: string }>([ |
| 17 | + { mode: 'light', type: 'success', color: PALETTE.green[900] }, |
| 18 | + { mode: 'dark', type: 'success', color: PALETTE.green[300] }, |
| 19 | + { mode: 'light', type: 'error', color: PALETTE.red[900] }, |
| 20 | + { mode: 'dark', type: 'error', color: PALETTE.red[300] }, |
| 21 | + { mode: 'light', type: 'warning', color: PALETTE.yellow[900] }, |
| 22 | + { mode: 'dark', type: 'warning', color: PALETTE.yellow[300] }, |
| 23 | + { mode: 'light', type: 'info', color: PALETTE.grey[900] }, |
| 24 | + { mode: 'dark', type: 'info', color: PALETTE.grey[300] } |
| 25 | + ])('renders correct $mode type $type title color', ({ mode, type, color }) => { |
| 26 | + const { container } = getRenderFn(mode)(<StyledAlert $type={type} />); |
23 | 27 |
|
24 | | - Object.values(validationHues).forEach(hue => { |
25 | | - const { container } = render(<StyledAlert hue={hue} />); |
26 | | - |
27 | | - expect(container.firstChild).toHaveStyleRule('color', getColorV8(hue, 800, DEFAULT_THEME), { |
28 | | - modifier: css` |
29 | | - ${StyledTitle} |
30 | | - ` as any |
31 | | - }); |
| 28 | + expect(container.firstChild).toHaveStyleRule('color', color, { |
| 29 | + modifier: css` |
| 30 | + ${StyledTitle} |
| 31 | + ` as any |
32 | 32 | }); |
33 | 33 | }); |
34 | 34 | }); |
0 commit comments