import React from 'react';
import { render, cleanup, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import '~tests/helpers/match-media.mock';
import Footer from '.';
import getFooterData from '../../../../tests/factories/modules/footer.factory';
import getPageData from '../../../../tests/factories/pages/default.factory';

describe('header component', () => {
  test('render', async () => {
    const { container } = render(
      <Footer
        section={getFooterData()}
        template="homepage"
        hasFooterLinks={false}
        footerTemplate="template_one"
      />
    );

    await waitFor(() => {
      expect(container.querySelectorAll('footer')).toHaveLength(1);
    });
  });
  test('Test new responsible gaming logos', async () => {
    const { container } = render(
      <Footer section={getFooterData()} template="homepage" page={getPageData()} />
    );

    await waitFor(() => {
      expect(container.querySelectorAll('.footer .logos li')).toHaveLength(3);
    });
  });
  test('Test when new responsible gaming logos are not available', async () => {
    const { container } = render(<Footer section={getFooterData()} template="homepage" />);

    await waitFor(() => {
      expect(container.querySelectorAll('.footer .logos li')).toHaveLength(3);
    });
  });
});
afterEach(() => {
  cleanup();
});
