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

import Image from '.';

describe('Image Component', () => {
  const imageModule = {
    alignment: 'align_right',
    alt: 'image alt',
    title: 'title',
    value: 'image.png',
  };
  test('render', () => {
    const { container } = render(<Image module={imageModule} />);
    expect(container).toBeTruthy();

    // Lazy image
    // expect(container.querySelector('img')).toBeFalsy();
    // expect(container.querySelector('div.lazyload-placeholder')).toBeTruthy();
  });

  test('render without data', () => {
    const { container } = render(<Image />);

    expect(container.querySelector('img')).toBeFalsy();
  });

  test('render without alt ', () => {
    delete imageModule.alt;
    const { container } = render(<Image module={imageModule} />);

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