import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render, screen } from '@testing-library/react';
import TemplateOneTwo from './index';
import getPaymentData from '../../../../../../tests/factories/cards/payment.factory';

describe('TemplateOneTwo component', () => {
  it('should return mock payment data', () => {
    const paymentData = getPaymentData();
    expect(paymentData.title).toBe('Payment Method Item Title');
    expect(paymentData.description).toBe(
      'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s,'
    );
    expect(paymentData.path).toBe('/');
    expect(paymentData.relation.name).toBe('Revolut');
    expect(paymentData.relation.selling_points.length).toBe(3);
    expect(paymentData.relation.games_count).toBe(10);
    expect(paymentData.relation.logo_filename_object.alt).toBe('Payment Method Item Logo');
    expect(paymentData.relation.logo_filename_object.filename).toBe('1652872814/revolut.svg');
    expect(paymentData.relation.rating).toBe('4.75');
  });
  it('renders the payment method name', () => {
    const paymentData = getPaymentData();
    render(<TemplateOneTwo item={paymentData} />);

    const nameElement = screen.getByText(paymentData.relation.name);
    expect(nameElement).toBeInTheDocument();
  });
  it('renders the "Read Review" button by default', () => {
    const paymentData = getPaymentData();
    render(<TemplateOneTwo item={paymentData} />);
    const buttonElement = screen.getByText('Read Review');
    expect(buttonElement).toBeInTheDocument();
  });
  it('renders the "Read Review" button when showSellingPoints is true', () => {
    const paymentData = getPaymentData();
    render(<TemplateOneTwo item={paymentData} showSellingPoints />);
    const buttonElement = screen.getByText('Read Review');
    expect(buttonElement).toBeInTheDocument();
  });

  it('renders the "Read Review" button when showSellingPoints is true', () => {
    const paymentData = getPaymentData();
    render(<TemplateOneTwo item={paymentData} />);
    const buttonElement = screen.getByText('Read Review');
    expect(buttonElement).toBeInTheDocument();
  });
  it('should render payment method title', () => {
    const paymentData = getPaymentData();
    render(<TemplateOneTwo item={paymentData} />);
    const titleElement = screen.getByText('Revolut');
    expect(titleElement).toBeInTheDocument();
  });
});
