import React from 'react';
import { render, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';

import { getToplistItem } from '../../../../../tests/factories/modules/toplist.factory';
import Row from './variant-one';

describe('toplist row component', () => {
  test('render row list format', async () => {
    const { container, getByText } = render(
      <Row item={getToplistItem()} tracker="main" itemRefs={{ current: {} }} />
    );
    expect(container).toBeTruthy();

    // Name
    expect(getByText('name1')).toBeTruthy();

    // Bonus
    expect(getByText('€100 welcome bonus')).toBeTruthy();
    expect(getByText('+150 free spins')).toBeTruthy();

    // Rating & Logo
    expect(container.querySelector('img')).toBeTruthy();

    // Selling Points
    expect(container.querySelectorAll('.sellingPoint li')).toHaveLength(2);
    expect(getByText('200% Bonus')).toBeTruthy();
    expect(getByText('Nice design')).toBeTruthy();

    // CTA
    expect(getByText('Visit').closest('a').getAttribute('href')).toEqual('/slotum');
  });
});
afterEach(() => {
  cleanup();
});
