Newer
Older
import UrgentRequest from './UrgentRequest';
import userEvent from '@testing-library/user-event';
const mockSendUrgent = jest.fn();
describe('<UrgentRequest>', () => {
it('renders the option to make a contact request urgent', () => {
);
const urgentFieldset = getByRole('group');
const urgentInput = getByRole('textbox');
const urgentSubmit = getByRole('button');
// See expected elements
expect(document.body.contains(urgentFieldset));
// Expected default values
expect(urgentInput).toHaveValue('');
expect(urgentSubmit).toBeDisabled();
// Try typing something that doesn't change the urgent status
userEvent.type(urgentInput, 'NOT URGENT');
expect(urgentInput).toHaveValue('NOT URGENT');
expect(urgentSubmit).toBeDisabled();
// Fill in URGENT to change the urgent status
userEvent.type(urgentInput, 'URGENT');
// State was updated..
expect(urgentInput).toHaveValue('URGENT');
expect(urgentSubmit).toBeEnabled();
// Can submit now..
urgentSubmit.onsubmit = mockSendUrgent;