summaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout/summary.test.tsx
blob: 7617c26a8b4a5d2d9017a69e87836a269dc8b089 (plain)
1
2
3
4
5
6
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp 
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();
  });
});