import React from 'react'; import { render } from '../../../test-utils/testing-library'; import Providers from '../Providers'; describe('elements/common/Providers', () => { test('renders children within Notification and TooltipProvider when hasProviders is true', () => { const screen = render(
Child Content
, ); expect(screen.getByText('Child Content')).toBeInTheDocument(); expect(screen.getByRole('region', { name: 'Notifications (F8)' })).toBeInTheDocument(); }); test('renders only children when hasProviders is false', () => { const screen = render(
Child Content
, ); expect(screen.getByText('Child Content')).toBeInTheDocument(); expect(screen.queryByRole('region', { name: 'Notifications (F8)' })).not.toBeInTheDocument(); }); test('throws an error if more than one child is provided when hasProviders is false', () => { expect(() => render(
Child 1
Child 2
, ), ).toThrow(); }); test('renders children within Notification and TooltipProvider by default when hasProviders is not provided', () => { const screen = render(
Child Content
, ); expect(screen.getByText('Child Content')).toBeInTheDocument(); expect(screen.getByRole('region', { name: 'Notifications (F8)' })).toBeInTheDocument(); }); });