From c87c615b5866b8a8f361eeb0764bfdea85740e90 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 10 Oct 2023 19:37:51 +0200
Subject: 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...).
---
 src/components/organisms/layout/overview.test.tsx | 30 ++++++++++++++---------
 1 file changed, 18 insertions(+), 12 deletions(-)

(limited to 'src/components/organisms/layout/overview.test.tsx')

diff --git a/src/components/organisms/layout/overview.test.tsx b/src/components/organisms/layout/overview.test.tsx
index 0f2af7b..b98bd6f 100644
--- a/src/components/organisms/layout/overview.test.tsx
+++ b/src/components/organisms/layout/overview.test.tsx
@@ -1,27 +1,33 @@
 import { describe, expect, it } from '@jest/globals';
-import { render, screen } from '../../../../tests/utils';
-import { Overview, type OverviewMeta } from './overview';
+import { render, screen as rtlScreen } from '../../../../tests/utils';
+import type { MetaItemData } from '../../molecules';
+import { Overview } from './overview';
 
 const cover = {
   alt: 'Incidunt unde quam',
   height: 480,
-  src: 'http://placeimg.com/640/480/cats',
+  src: 'https://picsum.photos/640/480',
   width: 640,
 };
 
-const data: OverviewMeta = {
-  creation: { date: '2022-05-09' },
-  license: 'Dignissimos ratione veritatis',
-};
+const meta = [
+  { id: 'creation-date', label: 'Creation date', value: '2022-05-09' },
+  { id: 'license', label: 'License', value: 'Dignissimos ratione veritatis' },
+] satisfies MetaItemData[];
 
 describe('Overview', () => {
-  it('renders some data', () => {
-    render(<Overview meta={data} />);
-    expect(screen.getByText(data.license!)).toBeInTheDocument();
+  it('renders some meta', () => {
+    render(<Overview meta={meta} />);
+
+    const metaLabels = meta.map((item) => item.label);
+
+    for (const label of metaLabels) {
+      expect(rtlScreen.getByText(label)).toBeInTheDocument();
+    }
   });
 
   it('renders a cover', () => {
-    render(<Overview cover={cover} meta={data} />);
-    expect(screen.getByRole('img', { name: cover.alt })).toBeInTheDocument();
+    render(<Overview cover={cover} meta={meta} />);
+    expect(rtlScreen.getByRole('img', { name: cover.alt })).toBeInTheDocument();
   });
 });
-- 
cgit v1.2.3

