From e7a787b4c4e2f2fb67b8f7768982b2bd3a06b46e Mon Sep 17 00:00:00 2001 From: SinusFox <61253950+SinusFox@users.noreply.github.com> Date: Fri, 11 Oct 2024 23:18:20 +0200 Subject: [PATCH] code fix --- __tests__/render_home_page.test.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/__tests__/render_home_page.test.js b/__tests__/render_home_page.test.js index fe02c2b..68ad71b 100644 --- a/__tests__/render_home_page.test.js +++ b/__tests__/render_home_page.test.js @@ -1,30 +1,31 @@ -import { render, screen, fireEvent, waitFor } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; -import Home from "../src/app/page"; +import Home from '../src/app/page'; import { customLog, customLogClear } from '../src/app/scripts'; -import { useRouter } from 'next/router'; - +// Mock customLog and customLogClear jest.mock('../src/app/scripts', () => ({ customLog: jest.fn(), customLogClear: jest.fn(), })); -jest.mock('next/router', () => ({ +// Mock next/navigation instead of next/router +jest.mock('next/navigation', () => ({ useRouter: jest.fn().mockReturnValue({ - push: jest.fn(), + push: jest.fn(), }), })); +// Mock GLPKAPI to avoid issues with undefined LPF_ECOND jest.mock('../src/solver/glpk.min.js', () => ({ LPF_ECOND: 2, })); test('render home page', () => { - // render website + // Render Home component render(); - // check if text is in document - const headingElement = screen.getByText(/OR-Tool/i); // text search in document + // Check if the heading text "OR-Tool" is present in the document + const headingElement = screen.getByText(/OR-Tool/i); // Match text that contains "OR-Tool" expect(headingElement).toBeInTheDocument(); });