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

describe('ReviewLink', () => {
  it('Bonus Template operatorName', () => {
    const { container, getByText } = render(
      <ReviewLink template="bonus_pages" operatorName="Super Slot Operator" reviewPath="/review" />
    );
    expect(getByText('Super Slot Operator Bonus')).toBeInTheDocument();
    expect(container.querySelector('a').getAttribute('href')).toBe('/review');
  });

  it('Bonus Template pageName', () => {
    const { container, getByText } = render(
      <ReviewLink template="bonus_pages" pageName="Super Slot Page" reviewPath="/review" />
    );
    expect(getByText('Super Slot Page Bonus')).toBeInTheDocument();
    expect(container.querySelector('a').getAttribute('href')).toBe('/review');
  });

  it('Review Template operatorName', () => {
    const { container, getByText } = render(
      <ReviewLink template="review_pages" operatorName="Super Slot Operator" reviewPath="/review" />
    );

    expect(getByText('Super Slot Operator Review')).toBeInTheDocument();
    expect(container.querySelector('a').getAttribute('href')).toBe('/review');
  });

  it('Review Template pageName', () => {
    const { container, getByText } = render(
      <ReviewLink template="review_pages" pageName="Super Slot Page" reviewPath="/review" />
    );

    expect(getByText('Super Slot Page')).toBeInTheDocument();
    expect(container.querySelector('a').getAttribute('href')).toBe('/review');
  });
});

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