From b3ac82bba9605fa9d9c4b1d29c5a56a52e9de015 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Fri, 15 Apr 2022 17:38:16 +0200
Subject: chore: add a SocialMedia component

---
 .../organisms/widgets/social-media.test.tsx        | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 src/components/organisms/widgets/social-media.test.tsx

(limited to 'src/components/organisms/widgets/social-media.test.tsx')

diff --git a/src/components/organisms/widgets/social-media.test.tsx b/src/components/organisms/widgets/social-media.test.tsx
new file mode 100644
index 0000000..e40db30
--- /dev/null
+++ b/src/components/organisms/widgets/social-media.test.tsx
@@ -0,0 +1,33 @@
+import { render, screen } from '@test-utils';
+import SocialMedia, { Media } from './social-media';
+
+const media: Media[] = [
+  { name: 'Github', url: '#' },
+  { name: 'LinkedIn', url: '#' },
+];
+const title = 'Dolores ut ut';
+const titleLevel = 2;
+
+/**
+ * Next.js mock images with next/image component. So for now, I need to mock
+ * the svg files manually.
+ */
+jest.mock('@assets/images/social-media/github.svg', () => 'svg-file');
+jest.mock('@assets/images/social-media/linkedin.svg', () => 'svg-file');
+
+describe('SocialMedia', () => {
+  it('renders the widget title', () => {
+    render(<SocialMedia media={media} title={title} level={titleLevel} />);
+    expect(
+      screen.getByRole('heading', {
+        level: titleLevel,
+        name: new RegExp(title, 'i'),
+      })
+    ).toBeInTheDocument();
+  });
+
+  it('renders the correct number of items', () => {
+    render(<SocialMedia media={media} title={title} level={titleLevel} />);
+    expect(screen.getAllByRole('listitem')).toHaveLength(media.length);
+  });
+});
-- 
cgit v1.2.3

