mirror of
https://github.com/Since-3/Kuma.git
synced 2026-10-12 19:51:17 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { firstName, renderPlaceholders } from "@/src/modules/marketing/lib/placeholders";
|
|
|
|
describe("renderPlaceholders", () => {
|
|
it("ersetzt alle Platzhalter", () => {
|
|
expect(
|
|
renderPlaceholders(
|
|
"Hallo {vorname}, {anzahl} Kurse bei {studio}: {code} ({rabatt}, bis {gueltig_bis})",
|
|
{
|
|
vorname: "Anna",
|
|
studio: "Pilates Loft",
|
|
anzahl: 10,
|
|
code: "DANKE-ABC234",
|
|
rabatt: "10 %",
|
|
gueltig_bis: "31.10.2026",
|
|
}
|
|
)
|
|
).toBe("Hallo Anna, 10 Kurse bei Pilates Loft: DANKE-ABC234 (10 %, bis 31.10.2026)");
|
|
});
|
|
|
|
it("räumt auf, wenn der Name fehlt", () => {
|
|
expect(
|
|
renderPlaceholders("Alles Gute zum Geburtstag, {vorname}!", { vorname: "", studio: "X" })
|
|
).toBe("Alles Gute zum Geburtstag!");
|
|
expect(renderPlaceholders("Hallo {vorname},\n\nschön", { vorname: "", studio: "X" })).toBe(
|
|
"Hallo,\n\nschön"
|
|
);
|
|
});
|
|
|
|
it("lässt unbekannte geschweifte Klammern stehen", () => {
|
|
expect(renderPlaceholders("{foo} {studio}", { vorname: "", studio: "X" })).toBe("{foo} X");
|
|
});
|
|
});
|
|
|
|
describe("firstName", () => {
|
|
it("nimmt den ersten Teil des Namens", () => {
|
|
expect(firstName(" Anna Maria Schmidt ")).toBe("Anna");
|
|
expect(firstName(null)).toBe("");
|
|
});
|
|
});
|