/* eslint-disable no-multi-assign */
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { getSampleOperatorCards } from 'gatsby-core-theme/tests/factories/modules/card.factory';
import TemplateThree from '.';

describe('Game Cards', () => {
  test('Template Three Provider', () => {
    const card = getSampleOperatorCards().items[0];
    card.relation = {
      ...card.relation,
      game_provider: {
        name: 'Test Game Provider',
        path: 'test-game-provider-path',
      },
    };

    const { container, getByText } = render(<TemplateThree item={card} />);
    expect(getByText('Wildz Casino')).toBeTruthy();
    expect(getByText('Test Game Provider')).toBeTruthy();
    expect(getByText('Play now')).toBeTruthy();
    expect(container.querySelectorAll('a')).toHaveLength(4);
  });
  test('Template Three Operator', () => {
    const card = getSampleOperatorCards().items[0];
    card.extra_fields = {
      ...card.extra_fields,
      operator: {
        name: 'Test Game Operator',
        path: 'test-game-operator-path',
      },
    };

    const { container, getByText } = render(<TemplateThree useOneStarRating={false} item={card} />);
    expect(getByText('Wildz Casino')).toBeTruthy();
    expect(getByText('Test Game Operator')).toBeTruthy();
    expect(getByText('Play now')).toBeTruthy();
    expect(container.querySelectorAll('a')).toHaveLength(4);
  });
});

afterEach(() => {
  cleanup();
});
