aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout/summary.test.tsx
blob: 3e58e9a831e536297a0a84a254950cf519e4ed8b (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
import { describe, expect, it } from '@jest/globals';
import { render, screen } from '../../../../tests/utils';
import { Summary } from './summary';
import { cover, intro, meta, title, url } from './summary.fixture';

describe('Summary', () => {
  it('renders a title wrapped in a h2 element', () => {
    render(
      <Summary
        intro={intro}
        meta={meta}
        title={title}
        titleLevel={2}
        url={url}
      />
    );
    expect(
      screen.getByRole('heading', { level: 2, name: title })
    ).toBeInTheDocument();
  });

  it('renders an excerpt', () => {
    render(<Summary intro={intro} meta={meta} title={title} url={url} />);
    expect(screen.getByText(intro)).toBeInTheDocument();
  });

  it('renders a cover', () => {
    render(
      <Summary
        intro={intro}
        meta={{ ...meta, cover }}
        title={title}
        url={url}
      />
    );
    expect(screen.getByRole('img', { name: cover.alt })).toBeInTheDocument();
  });

  it('renders a link to the full post', () => {
    render(<Summary intro={intro} meta={meta} title={title} url={url} />);
    expect(screen.getByRole('link', { name: title })).toBeInTheDocument();
  });

  it('renders a read more link', () => {
    render(<Summary intro={intro} meta={meta} title={title} url={url} />);
    expect(
      screen.getByRole('link', { name: `Read more about ${title}` })
    ).toBeInTheDocument();
  });

  it('renders some meta', () => {
    render(<Summary intro={intro} meta={meta} title={title} url={url} />);
    expect(screen.getByText(meta.thematics![0].name)).toBeInTheDocument();
  });
});