diff --git a/components/molecules/Navbar/ItemBottom.js b/components/molecules/Navbar/ItemBottom.js
index 4649bc0..76577f3 100644
--- a/components/molecules/Navbar/ItemBottom.js
+++ b/components/molecules/Navbar/ItemBottom.js
@@ -16,9 +16,8 @@ const ItemBottom = ({ title, icon, link, activePath }) => {
{link ? (
) : (
{icon({ size: 20 })}
{title}
diff --git a/components/molecules/Navbar/ItemBottom.test.js b/components/molecules/Navbar/ItemBottom.test.js
index 89493c5..fe2d96a 100644
--- a/components/molecules/Navbar/ItemBottom.test.js
+++ b/components/molecules/Navbar/ItemBottom.test.js
@@ -1,24 +1,28 @@
-import { render } from '@testing-library/react';
+import "@testing-library/jest-dom";
+import { render, screen } from '@testing-library/react';
import ItemBottom from './ItemBottom';
import { DrawContext } from '@/pages/_app';
import { SessionProvider } from 'next-auth/react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { SlHome } from 'react-icons/sl';
+import NextRouter from 'next/router'
-jest.mock('next/router', () => ({
- useRouter: jest.fn().mockReturnValue({
- query: {
- 'payment-intent': 'pi_1J4JrjGswQjYFZwX0Z1Z1Z1Z',
- },
- }),
-}));
-
describe('ItemBottom', () => {
- it('should render the component', () => {
- const { container } = render(
+ let container;
+ let routerSpy;
+ const pushMock = jest.fn();
+ const setDrawMock = jest.fn();
+
+ beforeEach(() => {
+
+ routerSpy = jest.spyOn(NextRouter, 'useRouter').mockReturnValue({
+ push: pushMock,
+ });
+
+ const res = render(
-
+
{
,
);
+
+ container = res.container;
+ });
+
+ it('should render the component', () => {
expect(container).toMatchSnapshot();
});
+
+ it('should navigate to the link', () => {
+
+
+ const h6 = screen.getByText('Accueil');
+
+ expect(h6).toBeInTheDocument();
+ h6.click();
+
+ expect(pushMock).toHaveBeenCalledTimes(1);
+ expect(pushMock).toHaveBeenCalledWith('/');
+
+ expect(setDrawMock).toHaveBeenCalledTimes(1);
+ expect(setDrawMock).toHaveBeenCalledWith(false);
+ });
+
+
});