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

import Tnc from '.';

describe('Tnc Component', () => {
  test('render component', () => {
    const { container } = render(<Tnc />);
    expect(container).toBeTruthy();
  });
  test('render tnc collapsed', () => {
    const { container } = render(<Tnc />);
    expect(container.querySelector('button')).toBeTruthy();
    expect(container.querySelector('button').innerHTML).toBe('Terms and Conditions Apply');
    expect(container.querySelector('button').closest('div').querySelector('div').innerHTML).toBe(
      '18+ New Players only. Play responsibly.'
    );
    expect(container.querySelector('.isFixed')).toBeFalsy();
  });
  test('render tnc fixed', () => {
    const { container } = render(<Tnc hasCollapse={false} isFixed />);
    expect(container.querySelector('.isFixed')).toBeTruthy();
    expect(container.querySelector('.isFixed').innerHTML).toBe(
      '18+ New Players only. Play responsibly.'
    );
  });
  test('render tnc not fixed not collapsed', () => {
    const { container } = render(<Tnc hasCollapse={false} isFixed={false} />);
    expect(container.querySelector('.isFixed')).toBeFalsy();
    expect(container.querySelector('div').innerHTML).toBe(
      '18+ New Players only. Play responsibly.'
    );
  });
});
afterEach(() => {
  cleanup();
});
