feat: Proxy-APIs und Integrationstests für WebServices hinzugefügt
- Vier Proxy-Endpunkte implementiert: 1. gisStationsStatusDistrict 2. gisStationsStaticDistrict 3. gisStationsMeasurements 4. gisSystemStatic - API-Integrationstests mit Jest für alle Endpunkte erstellt: - Tests verwenden echte API-Responses statt Mock-Daten. - Erfolgreiche Anfragen mit gültigen Parametern getestet. - Fehlende Parameter und ungültige Parameter getestet. - Code enthält: - Dynamische URL-Generierung für Proxy-Weiterleitungen. - Prüfung von Headern, Statuscodes und JSON-Strukturen. - Unterstützung für CORS und OPTIONS-Anfragen. - Ergebnis: - Alle Tests erfolgreich bestanden. - APIs bereit für produktive Nutzung und Erweiterungen.
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
// utils/openInNewTab.test.js
|
||||
import { openInNewTab } from "./openInNewTab";
|
||||
|
||||
// Leaflet manuell mocken
|
||||
global.L = {
|
||||
Marker: class {
|
||||
constructor(options) {
|
||||
this.options = options || {};
|
||||
}
|
||||
},
|
||||
Polyline: class {
|
||||
constructor(options) {
|
||||
this.options = options || {};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
describe("Integrationstest für openInNewTab", () => {
|
||||
const mockWindowOpen = jest.fn();
|
||||
|
||||
beforeAll(() => {
|
||||
global.window = Object.create(window);
|
||||
window.open = mockWindowOpen;
|
||||
delete window.location;
|
||||
window.location = new URL("http://10.10.0.13");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mockWindowOpen.mockClear();
|
||||
});
|
||||
|
||||
it("soll den Link korrekt für einen Marker öffnen", () => {
|
||||
const marker = new L.Marker({ link: "cpl.aspx?ver=35&kue=24&id=50922" });
|
||||
openInNewTab(null, marker);
|
||||
|
||||
expect(mockWindowOpen).toHaveBeenCalledWith("http://10.10.0.13/talas5/devices/cpl.aspx?ver=35&kue=24&id=50922", "_blank");
|
||||
});
|
||||
|
||||
it("soll den Link korrekt für eine Polyline öffnen", () => {
|
||||
const polyline = new L.Polyline({ idLD: 50922 });
|
||||
openInNewTab(null, polyline);
|
||||
|
||||
expect(mockWindowOpen).toHaveBeenCalledWith("http://10.10.0.13/talas5/devices/cpl.aspx?id=50922", "_blank");
|
||||
});
|
||||
|
||||
it("soll einen Fehler ausgeben, wenn kein Link gefunden wird", () => {
|
||||
console.error = jest.fn();
|
||||
|
||||
openInNewTab();
|
||||
|
||||
expect(console.error).toHaveBeenCalledWith("Fehler: Es wurde kein gültiger Link gefunden.");
|
||||
expect(mockWindowOpen).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user