import React from 'react';
import { render, screen } from '@testing-library/react';
import Bonus from '.';

describe('Bonus', () => {
  const operator = {
    standardised_logo_url: 'logo-url',
    logo: 'standardised-logo',
    logo_url: 'logo-url',
    bonus: {
      rating: '4.5',
    },
    name: 'Rizk',
    url: 'operator-url',
    extra_fields: {
      terms_and_conditions_text_enabled: 'true',
    },
    status: 'active',
  };

  test('renders operator name', () => {
    render(<Bonus operator={operator} />);
    const operatorName = screen.getByText('Rizk');
    expect(operatorName).toBeInTheDocument();
  });

  test('renders operator bonus rating', () => {
    render(<Bonus operator={operator} />);
    const bonusRating = screen.getByText(operator.bonus.rating);
    expect(bonusRating).toBeInTheDocument();
  });

  test('renders operator CTA', () => {
    render(<Bonus operator={operator} />);
    const operatorCTA = screen.getByLabelText(`${operator.name} Link`);
    expect(operatorCTA).toBeInTheDocument();
  });

  test('renders operator TNC', () => {
    render(<Bonus operator={operator} tncEnable />);
    const operatorTNC = screen.getByText('18+ New Players only. Play responsibly.');
    expect(operatorTNC).toBeInTheDocument();
  });

  test('does not render operator TNC when tncEnable is false', () => {
    render(<Bonus operator={operator} tncEnable={false} />);
    const operatorTNC = screen.queryByText('18+ New Players only. Play responsibly.');
    expect(operatorTNC).not.toBeInTheDocument();
  });
});
