/* eslint-disable no-multi-assign */
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import getOperatorData from '../../../../tests/factories/pages/operator.factory';
import OperatorBannerHeader from '.';

describe('Operator Header Banner ', () => {
  test('Status Active', () => {
    const { container, getByText } = render(
      <OperatorBannerHeader operator={getOperatorData().relation} />
    );
    expect(getByText('Welcome Bonus')).toBeTruthy();
    expect(getByText('100% Bonus')).toBeTruthy();
    expect(getByText('+ Big Promotions')).toBeTruthy();
    expect(container.querySelectorAll('span')).toHaveLength(2);
    expect(container.querySelectorAll('a')).toHaveLength(2);
  });

  test('Status coming_soon', () => {
    const { getByText } = render(
      <OperatorBannerHeader operator={getOperatorData('coming_soon').relation} />
    );
    expect(getByText('coming soon')).toBeTruthy();
  });

  test('Status inactive', () => {
    const { getByText } = render(
      <OperatorBannerHeader operator={getOperatorData('inactive').relation} />
    );
    expect(getByText('inactive')).toBeTruthy();
  });

  test('Status not_recommended', () => {
    const { getByText } = render(
      <OperatorBannerHeader operator={getOperatorData('not_recommended').relation} />
    );
    expect(getByText('Welcome Bonus')).toBeTruthy();
  });

  test('Not having affiliate link', () => {
    const { container } = render(
      <OperatorBannerHeader
        operator={{
          name: '',
          status: 'active',
          links: {
            main: '',
          },
          one_liners: {
            main: {
              one_liner: '100% Bonus + Big Promotions',
            },
          },
        }}
      />
    );
    expect(container.querySelectorAll('div')).toHaveLength(0);
  });
});

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