blob: b31a00a3e7a22c1e8af34f1b2dcf83a4c83a8af1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import '@testing-library/jest-dom';
import React from 'react';
import { fireEvent } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { describe, expect, it } from 'vitest';
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
import { renderWithProviders } from '../renderWithProviders';
import routes from '../routes';
describe('Guest Login', async () => {
const memoryRouter = createMemoryRouter(routes, {
initialEntries: ['/guests/login'],
});
it('can log in', async () => {
const { getByLabelText, getByRole, findByLabelText } = renderWithProviders(
<RouterProvider router={memoryRouter} />
);
const user = userEvent.setup();
await user.type(getByLabelText(/first name/i), 'Michael');
await user.type(getByLabelText(/last name/i), 'Hunteman');
fireEvent.click(getByRole('button', { name: 'Log in' }));
expect(await findByLabelText(/accept/i)).not.toBeChecked();
expect(await findByLabelText(/decline/i)).toBeChecked();
expect(await findByLabelText(/email/i)).toHaveValue('');
expect(await findByLabelText(/party size/i)).toHaveValue(1);
expect(await findByLabelText(/message to the couple/i)).toHaveValue('');
});
});
|