aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/links/sharing-link/sharing-link.test.tsx
blob: 06cfb2220a470b2d886da838d112e8eb876351c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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');
  });
});