summaryrefslogtreecommitdiff
path: root/client/src/components/GuestLogin.test.tsx
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-09-27 08:43:02 -0700
committerMichael Hunteman <michael@huntm.net>2024-09-27 08:43:02 -0700
commita88f613da7e5567dbfdebd7df94f94507c47c6b5 (patch)
treeb10a6c1640c11672a940f8fa71cdf3d3485135d4 /client/src/components/GuestLogin.test.tsx
parent7ccca5ca18200388d10fca33a1d7095a0abfcd36 (diff)
Add vitests
Diffstat (limited to 'client/src/components/GuestLogin.test.tsx')
-rw-r--r--client/src/components/GuestLogin.test.tsx29
1 files changed, 29 insertions, 0 deletions
diff --git a/client/src/components/GuestLogin.test.tsx b/client/src/components/GuestLogin.test.tsx
new file mode 100644
index 0000000..b31a00a
--- /dev/null
+++ b/client/src/components/GuestLogin.test.tsx
@@ -0,0 +1,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('');
+ });
+});