aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/links/sharing-link/sharing-link.test.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-03 18:52:57 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commita3fb0aa94717aafae897ac293488c43a099c0b2b (patch)
treebb5c9fcb093779061cd11e08d94f30bbb3a9b854 /src/components/atoms/links/sharing-link/sharing-link.test.tsx
parentf914ff8376dd91c4f6f8ca149e1cb6becb622d88 (diff)
refactor(components): rewrite SharingLink component
* replace default label with label prop * simplify CSS rules
Diffstat (limited to 'src/components/atoms/links/sharing-link/sharing-link.test.tsx')
-rw-r--r--src/components/atoms/links/sharing-link/sharing-link.test.tsx83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/components/atoms/links/sharing-link/sharing-link.test.tsx b/src/components/atoms/links/sharing-link/sharing-link.test.tsx
new file mode 100644
index 0000000..06cfb22
--- /dev/null
+++ b/src/components/atoms/links/sharing-link/sharing-link.test.tsx
@@ -0,0 +1,83 @@
+import { describe, expect, it } from '@jest/globals';
+import { render, screen as rtlScreen } from '@testing-library/react';
+import { SharingLink, type SharingMedium } from './sharing-link';
+
+describe('SharingLink', () => {
+ it('render a Diaspora sharing link', () => {
+ const label = 'ab';
+ const medium: SharingMedium = 'diaspora';
+ const target = '/totam';
+
+ render(<SharingLink label={label} medium={medium} url={target} />);
+
+ const link = rtlScreen.getByRole('link', { name: label });
+
+ expect(link).toHaveAttribute('href', target);
+ expect(link).toHaveClass('link--diaspora');
+ });
+
+ it('render an Email sharing link', () => {
+ const label = 'ut';
+ const medium: SharingMedium = 'email';
+ const target = '/nostrum';
+
+ render(<SharingLink label={label} medium={medium} url={target} />);
+
+ const link = rtlScreen.getByRole('link', { name: label });
+
+ expect(link).toHaveAttribute('href', target);
+ expect(link).toHaveClass('link--email');
+ });
+
+ it('render a Facebook sharing link', () => {
+ const label = 'autem';
+ const medium: SharingMedium = 'facebook';
+ const target = '/perspiciatis';
+
+ render(<SharingLink label={label} medium={medium} url={target} />);
+
+ const link = rtlScreen.getByRole('link', { name: label });
+
+ expect(link).toHaveAttribute('href', target);
+ expect(link).toHaveClass('link--facebook');
+ });
+
+ it('render a Journal du Hacker sharing link', () => {
+ const label = 'in';
+ const medium: SharingMedium = 'journal-du-hacker';
+ const target = '/labore';
+
+ render(<SharingLink label={label} medium={medium} url={target} />);
+
+ const link = rtlScreen.getByRole('link', { name: label });
+
+ expect(link).toHaveAttribute('href', target);
+ expect(link).toHaveClass('link--journal-du-hacker');
+ });
+
+ it('render a LinkedIn sharing link', () => {
+ const label = 'id';
+ const medium: SharingMedium = 'linkedin';
+ const target = '/nesciunt';
+
+ render(<SharingLink label={label} medium={medium} url={target} />);
+
+ const link = rtlScreen.getByRole('link', { name: label });
+
+ expect(link).toHaveAttribute('href', target);
+ expect(link).toHaveClass('link--linkedin');
+ });
+
+ it('render a Twitter sharing link', () => {
+ const label = 'illum';
+ const medium: SharingMedium = 'twitter';
+ const target = '/consectetur';
+
+ render(<SharingLink label={label} medium={medium} url={target} />);
+
+ const link = rtlScreen.getByRole('link', { name: label });
+
+ expect(link).toHaveAttribute('href', target);
+ expect(link).toHaveClass('link--twitter');
+ });
+});