aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/widgets/social-media.test.tsx
blob: e40db30b6798568b5590ba47a29cbcd95c96f5af (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
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);
  });
});