aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout/cards-list.test.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-10 19:37:51 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commitc87c615b5866b8a8f361eeb0764bfdea85740e90 (patch)
treec27bda05fd96bbe3154472e170ba1abd5f9ea499 /src/components/organisms/layout/cards-list.test.tsx
parent15522ec9146f6f1956620355c44dea2a6a75b67c (diff)
refactor(components): replace Meta component with MetaList
It removes items complexity by allowing consumers to use any label/value association. Translations should also be defined by the consumer. Each item can now be configured separately (borders, layout...).
Diffstat (limited to 'src/components/organisms/layout/cards-list.test.tsx')
-rw-r--r--src/components/organisms/layout/cards-list.test.tsx39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/components/organisms/layout/cards-list.test.tsx b/src/components/organisms/layout/cards-list.test.tsx
index 751a502..c9d6ae7 100644
--- a/src/components/organisms/layout/cards-list.test.tsx
+++ b/src/components/organisms/layout/cards-list.test.tsx
@@ -1,5 +1,5 @@
import { describe, expect, it } from '@jest/globals';
-import { render, screen } from '../../../../tests/utils';
+import { render, screen as rtlScreen } from '../../../../tests/utils';
import { CardsList, type CardsListItem } from './cards-list';
const items: CardsListItem[] = [
@@ -7,11 +7,21 @@ const items: CardsListItem[] = [
id: 'card-1',
cover: {
alt: 'card 1 picture',
- src: 'http://placeimg.com/640/480',
+ src: 'https://picsum.photos/640/480',
width: 640,
height: 480,
},
- meta: { thematics: ['Velit', 'Ex', 'Alias'] },
+ meta: [
+ {
+ id: 'categories',
+ label: 'Categories',
+ value: [
+ { id: 'velit', value: 'Velit' },
+ { id: 'ex', value: 'Ex' },
+ { id: 'alias', value: 'Alias' },
+ ],
+ },
+ ],
tagline: 'Molestias ut error',
title: 'Et alias omnis',
url: '#',
@@ -20,11 +30,11 @@ const items: CardsListItem[] = [
id: 'card-2',
cover: {
alt: 'card 2 picture',
- src: 'http://placeimg.com/640/480',
+ src: 'https://picsum.photos/640/480',
width: 640,
height: 480,
},
- meta: { thematics: ['Voluptas'] },
+ meta: [{ id: 'categories', label: 'Categories', value: 'Voluptas' }],
tagline: 'Quod vel accusamus',
title: 'Laboriosam doloremque mollitia',
url: '#',
@@ -33,13 +43,22 @@ const items: CardsListItem[] = [
id: 'card-3',
cover: {
alt: 'card 3 picture',
- src: 'http://placeimg.com/640/480',
+ src: 'https://picsum.photos/640/480',
width: 640,
height: 480,
},
- meta: {
- thematics: ['Quisquam', 'Quia', 'Sapiente', 'Perspiciatis'],
- },
+ meta: [
+ {
+ id: 'categories',
+ label: 'Categories',
+ value: [
+ { id: 'quisquam', value: 'Quisquam' },
+ { id: 'quia', value: 'Quia' },
+ { id: 'sapiente', value: 'Sapiente' },
+ { id: 'perspiciatis', value: 'Perspiciatis' },
+ ],
+ },
+ ],
tagline: 'Quo error eum',
title: 'Magni rem nulla',
url: '#',
@@ -49,7 +68,7 @@ const items: CardsListItem[] = [
describe('CardsList', () => {
it('renders a list of cards', () => {
render(<CardsList items={items} titleLevel={2} />);
- expect(screen.getAllByRole('heading', { level: 2 })).toHaveLength(
+ expect(rtlScreen.getAllByRole('heading', { level: 2 })).toHaveLength(
items.length
);
});