import { render, screen, userEvent, mockMatchMedia } from '../test-utils';
import { Position } from '../common';
import Drawer, { type DrawerProps } from './Drawer';
jest.mock('../common/DOMOperations');
mockMatchMedia();
describe('Drawer', () => {
const renderedComponent = (props: DrawerProps) => render(
Drawer Content
, className: 'drawer-class', }; beforeEach(() => { jest.clearAllMocks(); }); it('renders the Drawer component', () => { renderedComponent(props); expect(screen.getByRole('dialog')).toBeInTheDocument(); }); it('renders the header title', () => { renderedComponent(props); expect(screen.getByText('Drawer Title')).toBeInTheDocument(); }); it('renders the footer content', () => { renderedComponent(props); expect(screen.getByText('Footer Content')).toBeInTheDocument(); }); it('renders the children content', () => { renderedComponent(props); expect(screen.getByText('Drawer Content')).toBeInTheDocument(); }); it('passes through the className prop', () => { renderedComponent({ ...props, className: 'drawer-class' }); expect(screen.getByRole('dialog')).toHaveClass('drawer-class'); }); it('calls onClose when the close button is clicked', async () => { renderedComponent(props); await userEvent.click(screen.getByLabelText('Close')); expect(props.onClose).toHaveBeenCalled(); }); it('calls onClose if the dimmer is clicked', async () => { render(