aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/comment/reply-comment-form/reply-comment-form.test.tsx
blob: f02dd4890811181bdffe37bb5a4e4445985f30dc (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
import { describe, expect, it } from '@jest/globals';
import { render, screen as rtlScreen } from '../../../../../tests/utils';
import { Heading } from '../../../atoms';
import { ReplyCommentForm } from './reply-comment-form';

describe('ReplyCommentForm', () => {
  it('renders a form with a heading', () => {
    const commentId = 5;
    const heading = 'odio autem voluptas';
    const headingLvl = 3;

    render(
      <ReplyCommentForm
        commentId={commentId}
        heading={<Heading level={headingLvl}>{heading}</Heading>}
      />
    );

    expect(
      rtlScreen.getByRole('heading', { level: headingLvl })
    ).toHaveTextContent(heading);
    expect(rtlScreen.getByRole('form')).toHaveAccessibleName(
      `Leave a reply to comment ${commentId}`
    );
  });
});
class="kr">from '../../services/graphql'; import type { Article } from '../../types'; import { CONFIG } from '../config'; import { ROUTES } from '../constants'; /** * Retrieve the data for all the articles. * * @returns {Promise<Article[]>} - All the articles. */ const getAllArticles = async (): Promise<Article[]> => { const totalArticles = await getTotalArticles(); const rawArticles = await getArticles({ first: totalArticles }); const articles: Article[] = []; rawArticles.edges.forEach((edge) => { articles.push(getArticleFromRawData(edge.node)); }); return articles; }; /** * Generate a new feed. * * @returns {Promise<Feed>} - The feed. */ export const generateFeed = async (): Promise<Feed> => { const author = { name: CONFIG.name, email: process.env.APP_AUTHOR_EMAIL, link: CONFIG.url, }; const copyright = `${CONFIG.name} CC BY SA ${CONFIG.copyright.startYear} - ${CONFIG.copyright.endYear}`; const title = `${CONFIG.name} | ${CONFIG.baseline}`; const feed = new Feed({ author, copyright, description: process.env.APP_FEED_DESCRIPTION, feedLinks: { json: `${CONFIG.url}${ROUTES.RSS}/json`, atom: `${CONFIG.url}${ROUTES.RSS}/atom`, }, generator: 'Feed & NextJS', id: CONFIG.url, language: CONFIG.locales.defaultLocale, link: CONFIG.url, title, }); const articles = await getAllArticles(); articles.forEach((article) => { feed.addItem({ content: article.intro, date: new Date(article.meta.dates.publication), description: article.intro, id: `${article.id}`, link: `${CONFIG.url}${ROUTES.ARTICLE}/${article.slug}`, title: article.title, }); }); return feed; };