aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout/comment.test.tsx
blob: 66003d1160e6fed9298d0d06b2a0d115d9f64d28 (plain)
1
2
3
4
5
6
7
8
9
10
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.
import { render, screen } from '@test-utils';
import Comment from './comment';
import {
  author,
  data,
  formattedDate,
  formattedTime,
  id,
} from './comment.fixture';

describe('Comment', () => {
  it('renders an avatar', () => {
    render(<Comment canReply={true} {...data} />);
    expect(
      screen.getByRole('img', { name: author.avatar.alt })
    ).toBeInTheDocument();
  });

  it('renders the author website url', () => {
    render(<Comment canReply={true} {...data} />);
    expect(screen.getByRole('link', { name: author.name })).toHaveAttribute(
      'href',
      author.website
    );
  });

  it('renders a permalink to the comment', () => {
    render(<Comment canReply={true} {...data} />);
    expect(
      screen.getByRole('link', {
        name: `${formattedDate} at ${formattedTime}`,
      })
    ).toHaveAttribute('href', `/#comment-${id}`);
  });

  it('renders a reply button', () => {
    render(<Comment canReply={true} {...data} />);
    expect(screen.getByRole('button', { name: 'Reply' })).toBeInTheDocument();
  });

  it('does not render a reply button', () => {
    render(<Comment canReply={false} {...data} />);
    expect(
      screen.queryByRole('button', { name: 'Reply' })
    ).not.toBeInTheDocument();
  });
});