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

afterEach(cleanup);

test('should take a snapshot', () => {
	const { asFragment } = render(
		<div className="root">
			<Portal id="tester">Content</Portal>
		</div>
	);

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

describe('Tests Portal', () => {
	test('should mount to an existing id', () => {
		const { asFragment } = render(
			<div className="root">
				<Portal id="tester">Content</Portal>
				<div id="tester">Existing element</div>
			</div>
		);
		expect(asFragment()).toMatchSnapshot();
	});
});
