mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
fixed tests
This commit is contained in:
parent
e0897ff536
commit
8d44d09c54
3 changed files with 18 additions and 6 deletions
|
|
@ -1,11 +1,16 @@
|
|||
import React from 'react';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import AdminDrawer from '../../../components/AdminDrawer/AdminDrawer';
|
||||
import { BrowserRouter as Router } from 'react-router-dom'; // Import Router
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
describe('AdminDrawer Component', () => {
|
||||
test('renders the Admin button', () => {
|
||||
render(<AdminDrawer />);
|
||||
render(
|
||||
<Router>
|
||||
<AdminDrawer />
|
||||
</Router>
|
||||
);
|
||||
|
||||
// Check if the "Admin" button is in the document
|
||||
const button = screen.getByRole('button', { name: /admin/i });
|
||||
|
|
@ -13,7 +18,11 @@ describe('AdminDrawer Component', () => {
|
|||
});
|
||||
|
||||
test('opens the drawer when the button is clicked', () => {
|
||||
render(<AdminDrawer />);
|
||||
render(
|
||||
<Router>
|
||||
<AdminDrawer />
|
||||
</Router>
|
||||
);
|
||||
|
||||
// Click the "Admin" button
|
||||
const button = screen.getByRole('button', { name: /admin/i });
|
||||
|
|
@ -43,7 +52,11 @@ describe('AdminDrawer Component', () => {
|
|||
});
|
||||
*/
|
||||
test('menu items render correctly', () => {
|
||||
render(<AdminDrawer />);
|
||||
render(
|
||||
<Router>
|
||||
<AdminDrawer />
|
||||
</Router>
|
||||
);
|
||||
|
||||
// Open the drawer
|
||||
const button = screen.getByRole('button', { name: /admin/i });
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ describe("AdminTable Component", () => {
|
|||
const deleteButton = screen.getAllByRole("button")[0];
|
||||
|
||||
fireEvent.click(deleteButton);
|
||||
expect(screen.getByText("Confirm Deletion")).toBeInTheDocument();
|
||||
expect(screen.getByText("Confirmation")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: /cancel/i }));
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText("Confirm Deletion")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Confirmation")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
//TESTS ON ImageGallery.test.tsx
|
||||
Loading…
Reference in a new issue