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

function render({ children = 'Paper', ...props }) {
  return trender(<Paper {...props}>{children}</Paper>);
}

afterEach(cleanup);

describe('Paper', () => {
  test('should be well formed', async () => {
    const { container } = render({});
    expect(await axe(container)).toHaveNoViolations();
  });

  test('should have correct elevations', async () => {
    const { rerender, getByTestId } = render({});

    // Default elevation should be 100.
    const paper = getByTestId('paper-elevation-100');
    expect(paper).toHaveClass('as--elevation-100');

    // Changing elevation should change class.
    rerender(<Paper elevation={600}>Paper 600</Paper>);
    expect(paper).toHaveClass('as--elevation-600');
  });
});
