Skip to content

Commit

Permalink
Split color prop test by collections
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkudrna committed Sep 11, 2024
1 parent 5bcecab commit c41f5ed
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/components/Alert/__tests__/Alert.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
within,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { colorPropTest } from '../../../../tests/propTests/colorPropTest';
import { feedbackColorPropTest } from '../../../../tests/propTests/feedbackColorPropTest';
import { neutralColorPropTest } from '../../../../tests/propTests/neutralColorPropTest';
import defaultTranslations from '../../../translations/en';
import { Alert } from '../Alert';

Expand All @@ -20,7 +21,8 @@ describe('rendering', () => {
{ children: <div>content text</div> },
(rootElement) => expect(within(rootElement).getByText('content text')),
],
...colorPropTest,
...feedbackColorPropTest,
...neutralColorPropTest,
[
{ icon: (<div>icon</div>) },
(rootElement) => expect(within(rootElement).getByText('icon')),
Expand Down
6 changes: 4 additions & 2 deletions src/components/Badge/__tests__/Badge.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
render,
within,
} from '@testing-library/react';
import { colorPropTest } from '../../../../tests/propTests/colorPropTest';
import { feedbackColorPropTest } from '../../../../tests/propTests/feedbackColorPropTest';
import { neutralColorPropTest } from '../../../../tests/propTests/neutralColorPropTest';
import { Badge } from '../Badge';

const mandatoryProps = {
Expand All @@ -12,7 +13,8 @@ const mandatoryProps = {

describe('rendering', () => {
it.each([
...colorPropTest,
...feedbackColorPropTest,
...neutralColorPropTest,
[
{ label: 'label text' },
(rootElement) => expect(within(rootElement).getByText('label text')),
Expand Down
6 changes: 4 additions & 2 deletions src/components/Button/__tests__/Button.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
import userEvent from '@testing-library/user-event';
import { actionColorPropTest } from '../../../../tests/propTests/actionColorPropTest';
import { blockPropTest } from '../../../../tests/propTests/blockPropTest';
import { colorPropTest } from '../../../../tests/propTests/colorPropTest';
import { feedbackColorPropTest } from '../../../../tests/propTests/feedbackColorPropTest';
import { neutralColorPropTest } from '../../../../tests/propTests/neutralColorPropTest';
import { refPropTest } from '../../../../tests/propTests/refPropTest';
import { labelPropTest } from '../../../../tests/propTests/labelPropTest';
import { sizePropTest } from '../../../../tests/propTests/sizePropTest';
Expand Down Expand Up @@ -67,7 +68,8 @@ describe('rendering', () => {
],
...actionColorPropTest,
...blockPropTest,
...colorPropTest,
...feedbackColorPropTest,
...neutralColorPropTest,
[
{ disabled: true },
(rootElement) => expect(rootElement).toBeDisabled(),
Expand Down
6 changes: 4 additions & 2 deletions src/components/Card/__tests__/Card.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
render,
within,
} from '@testing-library/react';
import { colorPropTest } from '../../../../tests/propTests/colorPropTest';
import { feedbackColorPropTest } from '../../../../tests/propTests/feedbackColorPropTest';
import { neutralColorPropTest } from '../../../../tests/propTests/neutralColorPropTest';
import { raisedPropTest } from '../../../../tests/propTests/raisedPropTest';
import { ScrollView } from '../../ScrollView';
import { Card } from '../Card';
Expand Down Expand Up @@ -33,7 +34,8 @@ describe('rendering', () => {
{ children: <ScrollView>scroll view content</ScrollView> },
(rootElement) => expect(within(rootElement).getByText('scroll view content')),
],
...colorPropTest,
...feedbackColorPropTest,
...neutralColorPropTest,
...densePropTest('Root'),
[
{ disabled: true },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export const colorPropTest = [
[
{ color: 'dark' },
(rootElement) => expect(rootElement).toHaveClass('isRootColorDark'),
],
export const feedbackColorPropTest = [
[
{ color: 'danger' },
(rootElement) => expect(rootElement).toHaveClass('isRootColorDanger'),
Expand All @@ -15,10 +11,6 @@ export const colorPropTest = [
{ color: 'info' },
(rootElement) => expect(rootElement).toHaveClass('isRootColorInfo'),
],
[
{ color: 'light' },
(rootElement) => expect(rootElement).toHaveClass('isRootColorLight'),
],
[
{ color: 'note' },
(rootElement) => expect(rootElement).toHaveClass('isRootColorNote'),
Expand Down
10 changes: 10 additions & 0 deletions tests/propTests/neutralColorPropTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const neutralColorPropTest = [
[
{ color: 'dark' },
(rootElement) => expect(rootElement).toHaveClass('isRootColorDark'),
],
[
{ color: 'light' },
(rootElement) => expect(rootElement).toHaveClass('isRootColorLight'),
],
];

0 comments on commit c41f5ed

Please sign in to comment.