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

afterEach(cleanup);

test('should take a snapshot', () => {
	const { asFragment } = render(<Fade />);

	expect(asFragment()).toMatchSnapshot();
});

describe('Tests Fade with and without children', () => {
	test('renders a Fade without children', () => {
		const { getByTestId } = render(<Fade data-testid="fade-id" isVisible />);

		expect(getByTestId('fade-id')).toBeInTheDocument();
	});

	test('renders a Fade with children', () => {
		const { getByTestId } = render(
			<Fade data-testid="fade-id" isVisible>
				<p data-testid="child-id">Child Content</p>
			</Fade>
		);

		expect(getByTestId('fade-id')).toBeInTheDocument();
		expect(getByTestId('fade-id')).toContainElement(getByTestId('child-id'));
	});
});
