Jenkins-test

This commit is contained in:
ISA
2024-07-11 08:24:18 +02:00
parent 3bbbfeb872
commit 3ea4ce99b5
12 changed files with 4261 additions and 851 deletions

View File

@@ -1,8 +1,40 @@
// __tests__/MapComponent.test.js
import { render, screen } from "@testing-library/react";
import React from "react";
import { render } from "@testing-library/react";
import { RecoilRoot } from "recoil";
import MapComponent from "../components/MapComponent";
test("renders map component", () => {
render(<MapComponent />);
expect(screen.getByText("TALAS.Map")).toBeInTheDocument();
// Mock Leaflet and its plugins
jest.mock("leaflet", () => {
const leaflet = jest.requireActual("leaflet");
return {
...leaflet,
map: () => ({
setView: jest.fn(),
addLayer: jest.fn(),
}),
tileLayer: () => ({
addTo: jest.fn(),
}),
marker: () => ({
addTo: jest.fn(),
}),
};
});
jest.mock("leaflet-contextmenu", () => ({}));
// Mock the fetch API
global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve([]), // Adjust the mock data as needed
})
);
test("renders map component", () => {
render(
<RecoilRoot>
<MapComponent />
</RecoilRoot>
);
});