import React from 'react';
import { render, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';

import { authorObject } from '~tests/factories/modules/author-box.factory';
import AuthorBox from '.';

describe('author box component', () => {
  test('render', () => {
    const author = authorObject;
    const { container, getByText } = render(<AuthorBox author={author} />);
    expect(container).toBeTruthy();
    expect(getByText('Ida Moen Olsen')).toBeTruthy();
    expect(getByText('Casino Specialist')).toBeTruthy();
    expect(container.querySelectorAll('.contactLinks a')).toBeTruthy();
    expect(container.querySelectorAll('.socialIcons a')).toBeTruthy();
  });

  test('render with read more ', async () => {
    const author = authorObject;

    author.biography =
      "The purpose of lorem ipsum is to create a natural looking block of text (sentence, paragraph, page, etc.) that doesn't distract from the layout.";

    const { container, getByText } = render(<AuthorBox author={author} />);

    expect(container).toBeTruthy();
    expect(getByText(author.biography)).toBeTruthy();
  });
});
afterEach(() => {
  cleanup();
});
