frigate/web/src/components/__tests__/Dialog.test.jsx

24 lines
588 B
React
Raw Normal View History

import { h } from 'preact';
import Dialog from '../Dialog';
2022-02-27 17:04:12 +03:00
import { render, screen } from '@testing-library/preact';
describe('Dialog', () => {
let portal;
beforeAll(() => {
portal = document.createElement('div');
portal.id = 'dialogs';
document.body.appendChild(portal);
});
afterAll(() => {
document.body.removeChild(portal);
});
test('renders to a portal', async () => {
2022-02-27 17:04:12 +03:00
render(<Dialog>Sample</Dialog>);
expect(screen.getByText('Sample')).toBeInTheDocument();
expect(screen.getByRole('modal').closest('#dialogs')).not.toBeNull();
});
});