aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout/summary.test.tsx
blob: 7617c26a8b4a5d2d9017a69e87836a269dc8b089 (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
import { render, screen } from '@test-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();
  });
});