From a88f613da7e5567dbfdebd7df94f94507c47c6b5 Mon Sep 17 00:00:00 2001
From: Michael Hunteman <michael@huntm.net>
Date: Fri, 27 Sep 2024 08:43:02 -0700
Subject: Add vitests

---
 client/src/components/AdminLogin.test.tsx | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 client/src/components/AdminLogin.test.tsx

(limited to 'client/src/components/AdminLogin.test.tsx')

diff --git a/client/src/components/AdminLogin.test.tsx b/client/src/components/AdminLogin.test.tsx
new file mode 100644
index 0000000..feffadf
--- /dev/null
+++ b/client/src/components/AdminLogin.test.tsx
@@ -0,0 +1,30 @@
+import '@testing-library/jest-dom';
+import React from 'react';
+import { fireEvent, screen } 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('Admin Login', async () => {
+  const memoryRouter = createMemoryRouter(routes, {
+    initialEntries: ['/admin/login'],
+  });
+  it('can log in', async () => {
+    const { getByLabelText, getByRole, findByText } = renderWithProviders(
+      <RouterProvider router={memoryRouter} />
+    );
+    const user = userEvent.setup();
+
+    await user.type(getByLabelText(/username/i), 'username');
+    await user.type(getByLabelText(/password/i), 'password');
+    fireEvent.click(getByRole('button', { name: 'Log in' }));
+    expect(await findByText(/first name/i)).toBeInTheDocument();
+    expect(await findByText(/last name/i)).toBeInTheDocument();
+    expect(await findByText(/attendance/i)).toBeInTheDocument();
+    expect(await findByText(/email/i)).toBeInTheDocument();
+    expect(await findByText(/message/i)).toBeInTheDocument();
+    expect(await findByText(/party size/i)).toBeInTheDocument();
+  });
+});
-- 
cgit v1.2.3

