diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-24 16:18:02 +0200 | 
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-24 16:18:02 +0200 | 
| commit | c347190a4307c172d15dac156da86567098035f6 (patch) | |
| tree | bb0744acd041fe6a0afa2fb9e7a76c77e018a7f9 /src/components | |
| parent | e1cc2de22fc703d94e1151beb9526d8cbe0e49c1 (diff) | |
test: fix theme toggle and comment tests
Diffstat (limited to 'src/components')
4 files changed, 7 insertions, 30 deletions
| diff --git a/src/components/molecules/forms/prism-theme-toggle.test.tsx b/src/components/molecules/forms/prism-theme-toggle.test.tsx index d831b82..c9d7894 100644 --- a/src/components/molecules/forms/prism-theme-toggle.test.tsx +++ b/src/components/molecules/forms/prism-theme-toggle.test.tsx @@ -2,12 +2,12 @@ import { render, screen } from '@test-utils';  import PrismThemeToggle from './prism-theme-toggle';  describe('PrismThemeToggle', () => { -  it('renders a checked toggle (dark theme choice)', () => { +  it('renders a toggle component', () => {      render(<PrismThemeToggle />);      expect(        screen.getByRole('checkbox', {          name: `Code blocks: Light theme Dark theme`,        }) -    ).toBeChecked(); +    ).toBeInTheDocument();    });  }); diff --git a/src/components/molecules/forms/theme-toggle.test.tsx b/src/components/molecules/forms/theme-toggle.test.tsx index 89b4f6f..0600c5e 100644 --- a/src/components/molecules/forms/theme-toggle.test.tsx +++ b/src/components/molecules/forms/theme-toggle.test.tsx @@ -2,12 +2,12 @@ import { render, screen } from '@test-utils';  import ThemeToggle from './theme-toggle';  describe('ThemeToggle', () => { -  it('renders a checked toggle (dark theme choice)', () => { +  it('renders a toggle component', () => {      render(<ThemeToggle />);      expect(        screen.getByRole('checkbox', {          name: `Theme: Light theme Dark theme`,        }) -    ).toBeChecked(); +    ).toBeInTheDocument();    });  }); diff --git a/src/components/organisms/layout/comment.test.tsx b/src/components/organisms/layout/comment.test.tsx index 490a52b..66003d1 100644 --- a/src/components/organisms/layout/comment.test.tsx +++ b/src/components/organisms/layout/comment.test.tsx @@ -12,7 +12,7 @@ describe('Comment', () => {    it('renders an avatar', () => {      render(<Comment canReply={true} {...data} />);      expect( -      screen.getByRole('img', { name: 'Your name avatar' }) +      screen.getByRole('img', { name: author.avatar.alt })      ).toBeInTheDocument();    }); diff --git a/src/components/organisms/layout/comment.tsx b/src/components/organisms/layout/comment.tsx index 1dc2c71..f62f95c 100644 --- a/src/components/organisms/layout/comment.tsx +++ b/src/components/organisms/layout/comment.tsx @@ -11,21 +11,6 @@ import { type Comment as CommentSchema, type WithContext } from 'schema-dts';  import CommentForm, { type CommentFormProps } from '../forms/comment-form';  import styles from './comment.module.scss'; -export type CommentAuthor = { -  /** -   * The author avatar. -   */ -  avatar: string; -  /** -   * The author name. -   */ -  name: string; -  /** -   * The author website. -   */ -  url?: string; -}; -  export type CommentProps = Pick<    CommentType,    'approved' | 'content' | 'id' | 'meta' | 'parentId' @@ -72,14 +57,6 @@ const Comment: FC<CommentProps> = ({    const { author, date } = meta;    const [publicationDate, publicationTime] = date.split(' '); -  const avatarAltText = intl.formatMessage( -    { -      defaultMessage: '{author} avatar', -      description: 'Comment: avatar alternative text', -      id: 'T/hUiO', -    }, -    { author: author.name } -  );    const buttonLabel = isReplying      ? intl.formatMessage({          defaultMessage: 'Cancel reply', @@ -137,8 +114,8 @@ const Comment: FC<CommentProps> = ({            {author.avatar && (              <div className={styles.avatar}>                <Image -                src={author.avatar?.src} -                alt={avatarAltText} +                src={author.avatar.src} +                alt={author.avatar.alt}                  layout="fill"                  objectFit="cover"                  {...props} | 
