import { render, screen } from '@testing-library/react';
import Button from './Button';
import DeviceTypeProvider from './contexts/DeviceTypeProvider';
import Flex from './Flex';
import Modal from './Modal';
describe('Modal', () => {
test('Desktop Modal renders', () => {
const { baseElement } = render(
}
heading="Heading"
onDismiss={() => {}}
size="sm"
subHeading="Subheading"
>
Modal content
,
);
expect(baseElement).toMatchSnapshot();
});
test('Desktop Modal contains all elements correctly', () => {
render(
}
heading="Heading"
onDismiss={() => {}}
size="sm"
subHeading="Subheading"
>
Modal content
,
);
expect(screen.getByText('Heading')).toBeVisible();
expect(screen.getByText('Subheading')).toBeVisible();
expect(screen.getByText('Modal content')).toBeVisible();
expect(screen.getByText('Cancel')).toBeVisible();
expect(screen.getByText('Next')).toBeVisible();
expect(screen.getAllByRole('button')).toHaveLength(2);
expect(screen.getByLabelText('Test modal')).toBeVisible();
});
test('Mobile Modal renders', () => {
const { baseElement } = render(
}
heading="Heading"
onDismiss={() => {}}
size="sm"
subHeading="Subheading"
>
Modal content
,
);
expect(baseElement).toMatchSnapshot();
});
test('Mobile Modal contains all elements correctly', () => {
render(
}
heading="Heading"
onDismiss={() => {}}
size="sm"
subHeading="Subheading"
>
Modal content
,
);
expect(screen.getByText('Heading')).toBeVisible();
expect(screen.getByText('Subheading')).toBeVisible();
expect(screen.getByText('Modal content')).toBeVisible();
expect(screen.getByText('Cancel')).toBeVisible();
expect(screen.getByText('Next')).toBeVisible();
expect(screen.getAllByRole('button')).toHaveLength(3);
expect(screen.getByLabelText('Bottom sheet')).toBeVisible();
expect(screen.getByLabelText('Dismiss bottom sheet')).toBeVisible();
});
});