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/GlobalSnackbar.test.tsx | 28 +++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 client/src/components/GlobalSnackbar.test.tsx

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

diff --git a/client/src/components/GlobalSnackbar.test.tsx b/client/src/components/GlobalSnackbar.test.tsx
new file mode 100644
index 0000000..2643816
--- /dev/null
+++ b/client/src/components/GlobalSnackbar.test.tsx
@@ -0,0 +1,28 @@
+import '@testing-library/jest-dom';
+import React from 'react';
+import { describe, expect, it } from 'vitest';
+import { createMemoryRouter, RouterProvider } from 'react-router-dom';
+import { renderWithProviders } from '../renderWithProviders';
+import routes from '../routes';
+import { showSnackbar } from '../slices/snackbarSlice';
+import setupStore from '../store';
+
+describe('Global Snackbar', async () => {
+  const memoryRouter = createMemoryRouter(routes, {
+    initialEntries: ['/'],
+  });
+  it('displays message', async () => {
+    const store = setupStore();
+    store.dispatch(
+      showSnackbar({
+        message: 'message',
+        severity: 'success',
+      })
+    );
+    const { findByText } = renderWithProviders(
+      <RouterProvider router={memoryRouter} />,
+      { store }
+    );
+    expect(await findByText(/message/i)).toBeInTheDocument();
+  });
+});
-- 
cgit v1.2.3

