mirror of
https://github.com/Since-3/Kuma.git
synced 2026-10-12 20:41:16 +00:00
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { describeCancellationPolicy } from "@/src/modules/courses/lib/cancellation-summary";
|
|
|
|
const base = { enabled: true, mode: "tiered" as const, fixedRefundPercent: 100, tiers: [] };
|
|
|
|
describe("describeCancellationPolicy", () => {
|
|
it("beschreibt die Standardregel", () => {
|
|
expect(describeCancellationPolicy(base)).toBe("Kostenlos stornierbar bis Kursbeginn.");
|
|
});
|
|
|
|
it("beschreibt Staffeln in der Reihenfolge, in der sie greifen", () => {
|
|
expect(
|
|
describeCancellationPolicy({
|
|
...base,
|
|
tiers: [
|
|
{ hoursBeforeStart: 6, refundPercent: 0 },
|
|
{ hoursBeforeStart: 24, refundPercent: 50 },
|
|
{ hoursBeforeStart: 12, refundPercent: 25 },
|
|
],
|
|
})
|
|
).toBe(
|
|
"Kostenlos stornierbar bis 24 Stunden vor Kursbeginn, danach 50 % Erstattung, " +
|
|
"ab 12 Stunden vorher 25 % Erstattung, ab 6 Stunden vorher keine Erstattung."
|
|
);
|
|
});
|
|
|
|
it("beschreibt feste Sätze und deaktivierte Stornierung", () => {
|
|
expect(describeCancellationPolicy({ ...base, mode: "fixed", fixedRefundPercent: 50 })).toBe(
|
|
"Bei einer Stornierung werden 50 % erstattet."
|
|
);
|
|
expect(describeCancellationPolicy({ ...base, enabled: false })).toBe(
|
|
"Gebuchte Kurse können nicht online storniert werden."
|
|
);
|
|
});
|
|
});
|