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 Bonus from '.';

describe('Bonus Component', () => {
  test('render with props', () => {
    const item = getToplistItem();
    const { getByText } = render(<Bonus item={item} tracker="main" />);
    expect(getByText('€100 welcome bonus')).toBeTruthy();
  });
  test('render with main onliner', () => {
    const { getByText } = render(
      <Bonus
        item={{
          status: 'active',
          one_liners: {
            one_liner: 'welcome bonus',
          },
          bonus: {
            one_liners: {
              main: {
                one_liner: 'welcome bonus',
              },
              secondary: {
                one_liner: 'Welcome Bonus up to £1000',
              },
            },
          },
        }}
        tracker="main"
      />
    );
    expect(getByText('welcome bonus')).toBeTruthy();
    expect(getByText('Visit')).toBeTruthy();
  });
  test('without oneLiner', () => {
    const { queryByText } = render(
      <Bonus
        item={{
          one_liners: {},
          bonus: {},
        }}
        tracker="main"
      />
    );
    expect(queryByText('welcome bonus')).toBeNull();
  });
});
afterEach(() => {
  cleanup();
});
