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

import Iframe from '.';

describe('Iframe Component', () => {
  test('render', () => {
    const { container } = render(
      <Iframe src="http://google.com" title="mySimpleTitle" minHeight="10rem" lazyLoad={false} />
    );
    expect(container.querySelectorAll('div.iframeContainer')).toHaveLength(1);
    expect(container.querySelectorAll('iframe')).toHaveLength(1);
  });

  test('props', () => {
    const { container } = render(
      <Iframe src="http://google.com" title="mySimpleTitle" minHeight="10rem" lazyLoad={false} />
    );
    const iframe = container.querySelector('iframe');
    expect(iframe.getAttribute('title')).toEqual('mySimpleTitle');
    expect(iframe.getAttribute('style')).toEqual('width: 100%; min-height: 10rem; display: block;');
    expect(iframe.getAttribute('src')).toEqual('http://google.com');
  });
});
afterEach(() => {
  cleanup();
});
