import { HTMLAttributes } from 'react';
import { render } from '../test-utils';
import withNextPortalWrapper from './withNextPortal';
describe('withNextPortalWrapper', () => {
it('renders component in React portal', () => {
type Props = Pick<
HTMLAttributes,
'id' | 'children' | 'className' | 'aria-label'
>;
const RandomComponentForTest = withNextPortalWrapper((props: Props) => );
const data: Props = {
'aria-label': 'Test aria-label',
id: 'random-component',
children: 'Test Children',
};
render();
const componentDomRef = document.body.lastChild;
expect(componentDomRef).toHaveAttribute('aria-label', data['aria-label']);
expect(componentDomRef).toHaveTextContent(data.children as string);
expect(componentDomRef).toHaveAttribute('id', data.id);
});
});