Merge gmpl main2 (#37)
* addPage for gmpl * implement gmpl full_functional * final * del unused variable * change type of variable * change test * code fix * code fix * fixing var error (var -> let) --------- Co-authored-by: SinusFox <61253950+SinusFox@users.noreply.github.com>
This commit is contained in:
@@ -1,22 +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';
|
||||
|
||||
// Mock customLog and customLogClear
|
||||
jest.mock('../src/app/scripts', () => ({
|
||||
customLog: jest.fn(),
|
||||
customLogClear: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock next/navigation instead of next/router
|
||||
jest.mock('next/navigation', () => ({
|
||||
useRouter: jest.fn().mockReturnValue({
|
||||
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(<Home />);
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
||||
@@ -20,6 +20,13 @@ jest.mock('../src/solver/glpk.min.js', () => ({
|
||||
// Mocking console.log
|
||||
const consoleLogMock = jest.spyOn(console, 'log').mockImplementation(() => {});
|
||||
|
||||
// Mock useRouter to avoid invariant error
|
||||
jest.mock('next/navigation', () => ({
|
||||
useRouter: jest.fn(() => ({
|
||||
push: jest.fn(), // Mock the 'push' function
|
||||
})),
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `
|
||||
<div>
|
||||
@@ -90,7 +97,7 @@ test('calculate_click should display "Calculating" in the output box', () => {
|
||||
document.getElementById('bounds').value = 'x <= 5';
|
||||
document.getElementById('vars').value = 'x\ny';
|
||||
|
||||
// Simuliere den Button-Klick, der die Berechnung startet
|
||||
// Simulate the button click to trigger calculation
|
||||
fireEvent.click(screen.getByText('Calculate'));
|
||||
|
||||
// Check the contents of out box
|
||||
@@ -101,4 +108,3 @@ test('calculate_click should display "Calculating" in the output box', () => {
|
||||
mockClear.mockRestore();
|
||||
mockLog.mockRestore();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user