import React, { useState } from 'react'; import { render, cleanup, fireEvent, screen } from '../utilities/test-utils'; import { Drawer, Button } from 'playbook-ui'; const size = 'sm'; function DrawerTest({ props }) { const [isOpen, setIsOpen] = useState(false); const close = () => setIsOpen(false); const open = () => setIsOpen(true); return ( <> {props && props.children} ); } afterEach(cleanup); test('renders with the right border class when border prop is right', async () => { render(); fireEvent.click(screen.getByText('Open Drawer')); const drawer = await screen.findByRole('dialog'); expect(drawer).toHaveClass('drawer_border_right'); }); test('renders with the left border class when border prop is left', async () => { render(); fireEvent.click(screen.getByText('Open Drawer')); const drawer = await screen.findByRole('dialog'); expect(drawer).toHaveClass('drawer_border_left'); }); test('renders with the full border class when border prop is full', async () => { render(); fireEvent.click(screen.getByText('Open Drawer')); const drawer = await screen.findByRole('dialog'); expect(drawer).toHaveClass('drawer_border_full'); }); test('does not have a border class when border prop is none', async () => { render(); fireEvent.click(screen.getByText('Open Drawer')); const drawer = await screen.findByRole('dialog'); expect(drawer).not.toHaveClass('drawer_border_right'); expect(drawer).not.toHaveClass('drawer_border_left'); expect(drawer).not.toHaveClass('drawer_border_full'); }); test('renders the correct size class for a large drawer', async () => { render(); fireEvent.click(screen.getByText('Open Drawer')); const drawer = await screen.findByRole('dialog'); expect(drawer).toHaveClass('pb_drawer pb_drawer_lg_left'); });