fixed tests

This commit is contained in:
Eddi3_As 2025-04-10 19:18:52 -04:00
parent e0897ff536
commit 8d44d09c54
3 changed files with 18 additions and 6 deletions

View file

@ -1,11 +1,16 @@
import React from 'react'; import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react'; import { render, screen, fireEvent } from '@testing-library/react';
import AdminDrawer from '../../../components/AdminDrawer/AdminDrawer'; import AdminDrawer from '../../../components/AdminDrawer/AdminDrawer';
import { BrowserRouter as Router } from 'react-router-dom'; // Import Router
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
describe('AdminDrawer Component', () => { describe('AdminDrawer Component', () => {
test('renders the Admin button', () => { test('renders the Admin button', () => {
render(<AdminDrawer />); render(
<Router>
<AdminDrawer />
</Router>
);
// Check if the "Admin" button is in the document // Check if the "Admin" button is in the document
const button = screen.getByRole('button', { name: /admin/i }); const button = screen.getByRole('button', { name: /admin/i });
@ -13,7 +18,11 @@ describe('AdminDrawer Component', () => {
}); });
test('opens the drawer when the button is clicked', () => { test('opens the drawer when the button is clicked', () => {
render(<AdminDrawer />); render(
<Router>
<AdminDrawer />
</Router>
);
// Click the "Admin" button // Click the "Admin" button
const button = screen.getByRole('button', { name: /admin/i }); const button = screen.getByRole('button', { name: /admin/i });
@ -43,7 +52,11 @@ describe('AdminDrawer Component', () => {
}); });
*/ */
test('menu items render correctly', () => { test('menu items render correctly', () => {
render(<AdminDrawer />); render(
<Router>
<AdminDrawer />
</Router>
);
// Open the drawer // Open the drawer
const button = screen.getByRole('button', { name: /admin/i }); const button = screen.getByRole('button', { name: /admin/i });

View file

@ -50,10 +50,10 @@ describe("AdminTable Component", () => {
const deleteButton = screen.getAllByRole("button")[0]; const deleteButton = screen.getAllByRole("button")[0];
fireEvent.click(deleteButton); fireEvent.click(deleteButton);
expect(screen.getByText("Confirm Deletion")).toBeInTheDocument(); expect(screen.getByText("Confirmation")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: /cancel/i })); fireEvent.click(screen.getByRole("button", { name: /cancel/i }));
await waitFor(() => { await waitFor(() => {
expect(screen.queryByText("Confirm Deletion")).not.toBeInTheDocument(); expect(screen.queryByText("Confirmation")).not.toBeInTheDocument();
}); });
}); });

View file

@ -1 +0,0 @@
//TESTS ON ImageGallery.test.tsx