forked from fahrPool/fahrPool
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { validateSchichtKorrektur } from "./validate-korrektur";
|
|
|
|
describe("validateSchichtKorrektur", () => {
|
|
it("akzeptiert eine gueltige Geht-Uhrzeit nach der Kommt-Uhrzeit", () => {
|
|
const result = validateSchichtKorrektur({
|
|
gehtUm: "2026-07-13T14:00",
|
|
kommtUm: "2026-07-13T06:00:00.000Z",
|
|
});
|
|
expect(result.valid).toBe(true);
|
|
});
|
|
|
|
it("lehnt eine fehlende Geht-Uhrzeit ab", () => {
|
|
const result = validateSchichtKorrektur({ gehtUm: "", kommtUm: "2026-07-13T06:00:00.000Z" });
|
|
expect(result).toEqual({ valid: false, error: "Bitte eine Geht-Uhrzeit angeben." });
|
|
});
|
|
|
|
it("lehnt eine nicht parsebare Geht-Uhrzeit ab", () => {
|
|
const result = validateSchichtKorrektur({ gehtUm: "garbage", kommtUm: "2026-07-13T06:00:00.000Z" });
|
|
expect(result).toEqual({ valid: false, error: "Ungueltige Geht-Uhrzeit." });
|
|
});
|
|
|
|
it("lehnt eine Geht-Uhrzeit vor der Kommt-Uhrzeit ab", () => {
|
|
const result = validateSchichtKorrektur({
|
|
gehtUm: "2026-07-13T05:00",
|
|
kommtUm: "2026-07-13T06:00:00.000Z",
|
|
});
|
|
expect(result).toEqual({ valid: false, error: "Die Geht-Uhrzeit muss nach der Kommt-Uhrzeit liegen." });
|
|
});
|
|
|
|
it("lehnt eine Geht-Uhrzeit gleich der Kommt-Uhrzeit ab", () => {
|
|
const result = validateSchichtKorrektur({
|
|
gehtUm: "2026-07-13T06:00:00.000Z",
|
|
kommtUm: "2026-07-13T06:00:00.000Z",
|
|
});
|
|
expect(result.valid).toBe(false);
|
|
});
|
|
});
|