Skip to content

Commit 1b81444

Browse files
committed
chore: adds color tests for views
1 parent be05ccb commit 1b81444

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('StyledBase', () => {
2121
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[1000] },
2222
{ mode: 'light', type: 'info', color: PALETTE.grey[100] },
2323
{ mode: 'dark', type: 'info', color: PALETTE.grey[1000] }
24-
])('renders $mode mode $type background colors', ({ mode, type, color }) => {
24+
])('renders $mode mode $type background color', ({ mode, type, color }) => {
2525
const { container } = getRenderFn(mode)(<StyledBase $type={type} />);
2626

2727
expect(container.firstChild).toHaveStyleRule('background-color', color);
@@ -36,7 +36,7 @@ describe('StyledBase', () => {
3636
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[800] },
3737
{ mode: 'light', type: 'info', color: PALETTE.grey[300] },
3838
{ mode: 'dark', type: 'info', color: PALETTE.grey[800] }
39-
])('renders $mode mode $type border colors', ({ mode, type, color }) => {
39+
])('renders $mode mode $type border color', ({ mode, type, color }) => {
4040
const { container } = getRenderFn(mode)(<StyledBase $type={type} />);
4141

4242
expect(container.firstChild).toHaveStyleRule('border-color', color);
@@ -51,7 +51,7 @@ describe('StyledBase', () => {
5151
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[400] },
5252
{ mode: 'light', type: 'info', color: PALETTE.grey[700] },
5353
{ mode: 'dark', type: 'info', color: PALETTE.grey[500] }
54-
])('renders $mode mode $type foreground colors', ({ mode, type, color }) => {
54+
])('renders $mode mode $type foreground color', ({ mode, type, color }) => {
5555
const { container } = getRenderFn(mode)(<StyledBase $type={type} />);
5656

5757
expect(container.firstChild).toHaveStyleRule('color', color);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright Zendesk, Inc.
3+
*
4+
* Use of this source code is governed under the Apache License, Version 2.0
5+
* found at http://www.apache.org/licenses/LICENSE-2.0.
6+
*/
7+
8+
import React from 'react';
9+
import { getRenderFn } from 'garden-test-utils';
10+
import { PALETTE } from '@zendeskgarden/react-theming';
11+
import XStrokeIcon from '@zendeskgarden/svg-icons/src/16/x-stroke.svg';
12+
import { StyledIcon } from './StyledIcon';
13+
import { Type } from '../types';
14+
15+
describe('StyledIcon', () => {
16+
it.each<{ mode: 'light' | 'dark'; type: Type; color: string }>([
17+
{ mode: 'light', type: 'success', color: PALETTE.green[700] },
18+
{ mode: 'dark', type: 'success', color: PALETTE.green[400] },
19+
{ mode: 'light', type: 'error', color: PALETTE.red[700] },
20+
{ mode: 'dark', type: 'error', color: PALETTE.red[400] },
21+
{ mode: 'light', type: 'warning', color: PALETTE.yellow[700] },
22+
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[400] },
23+
{ mode: 'light', type: 'info', color: PALETTE.grey[700] },
24+
{ mode: 'dark', type: 'info', color: PALETTE.grey[500] }
25+
])('renders $mode mode $type color', ({ mode, type, color }) => {
26+
const { container } = getRenderFn(mode)(
27+
<StyledIcon $type={type}>
28+
<XStrokeIcon />
29+
</StyledIcon>
30+
);
31+
32+
expect(container.firstChild).toHaveStyleRule('color', color);
33+
});
34+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright Zendesk, Inc.
3+
*
4+
* Use of this source code is governed under the Apache License, Version 2.0
5+
* found at http://www.apache.org/licenses/LICENSE-2.0.
6+
*/
7+
8+
import React from 'react';
9+
import { getRenderFn } from 'garden-test-utils';
10+
import { PALETTE } from '@zendeskgarden/react-theming';
11+
import { StyledNotification } from './StyledNotification';
12+
import { Type } from '../types';
13+
import { StyledTitle } from './content/StyledTitle';
14+
import { css } from 'styled-components';
15+
16+
describe('StyledNotification', () => {
17+
it.each<{ mode: 'light' | 'dark'; type: Type; color: string }>([
18+
{ mode: 'light', type: 'success', color: PALETTE.green[700] },
19+
{ mode: 'dark', type: 'success', color: PALETTE.green[400] },
20+
{ mode: 'light', type: 'error', color: PALETTE.red[700] },
21+
{ mode: 'dark', type: 'error', color: PALETTE.red[400] },
22+
{ mode: 'light', type: 'warning', color: PALETTE.yellow[700] },
23+
{ mode: 'dark', type: 'warning', color: PALETTE.yellow[400] },
24+
{ mode: 'light', type: 'info', color: PALETTE.grey[900] },
25+
{ mode: 'dark', type: 'info', color: PALETTE.grey[300] }
26+
])('renders $mode mode $type color', ({ mode, type, color }) => {
27+
const { container } = getRenderFn(mode)(
28+
<StyledNotification $type={type}>
29+
<StyledTitle>title</StyledTitle>
30+
</StyledNotification>
31+
);
32+
33+
expect(container.firstChild).toHaveStyleRule('color', color, {
34+
modifier: css`
35+
${StyledTitle}
36+
` as any
37+
});
38+
});
39+
});

0 commit comments

Comments
 (0)