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

afterEach(cleanup);

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

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

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

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

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

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