feat: Wabenhain Honig-Shop Anwendung
Vollstaendige Next.js/Prisma-E-Commerce-Anwendung fuer eine Imkerei: Shop, Warenkorb, Stripe-Checkout, Kundenkonto mit 2FA, Admin-Bereich (Produkte, Ernten, Chargen, Bestellungen, Gutscheine, admin-editierbare Website-Inhalte), i18n (DE/EN), Rate-Limiting/CSP/Audit-Log-Haertung, PostgreSQL- und MySQL-Unterstuetzung ueber austauschbare Prisma- Treiber-Adapter, Unit-/Komponenten-/E2E-Tests.
This commit is contained in:
1 parent
5c76fcc266
commit
c7927f2883
240 files changed
+26096
-137
No files matched your search
@@ -0,0 +1,91 @@
|
||||
import { describe, test, expect } from "vitest";
|
||||
import { parseListSimple, parseListTitled, parseListNumbered, parseSections } from "./content-parsers";
|
||||
|
||||
describe("parseListSimple", () => {
|
||||
test("splits one item per line", () => {
|
||||
expect(parseListSimple("Erste Zeile\nZweite Zeile")).toEqual(["Erste Zeile", "Zweite Zeile"]);
|
||||
});
|
||||
|
||||
test("trims whitespace and drops blank lines", () => {
|
||||
expect(parseListSimple(" Erste \n\n \nZweite")).toEqual(["Erste", "Zweite"]);
|
||||
});
|
||||
|
||||
test("returns an empty array for empty input", () => {
|
||||
expect(parseListSimple("")).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseListTitled", () => {
|
||||
test("splits Title | Text pairs", () => {
|
||||
expect(parseListTitled("Regional | Aus der Region\nEhrlich | Klare Herkunft")).toEqual([
|
||||
{ title: "Regional", text: "Aus der Region" },
|
||||
{ title: "Ehrlich", text: "Klare Herkunft" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("trims whitespace around title and text", () => {
|
||||
expect(parseListTitled(" Regional | Aus der Region ")).toEqual([
|
||||
{ title: "Regional", text: "Aus der Region" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("keeps additional pipe characters as part of the text", () => {
|
||||
expect(parseListTitled("Regional | Text mit | einem Pipe-Zeichen")).toEqual([
|
||||
{ title: "Regional", text: "Text mit | einem Pipe-Zeichen" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("a line without a pipe becomes the title with empty text", () => {
|
||||
expect(parseListTitled("Nur ein Titel")).toEqual([{ title: "Nur ein Titel", text: "" }]);
|
||||
});
|
||||
|
||||
test("drops blank lines", () => {
|
||||
expect(parseListTitled("Regional | Text\n\n")).toEqual([{ title: "Regional", text: "Text" }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseListNumbered", () => {
|
||||
test("splits Nummer | Titel | Text triples", () => {
|
||||
expect(parseListNumbered("01 | Ernten | Von Hand geerntet\n02 | Schleudern | Kalt geschleudert")).toEqual([
|
||||
{ number: "01", title: "Ernten", text: "Von Hand geerntet" },
|
||||
{ number: "02", title: "Schleudern", text: "Kalt geschleudert" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("keeps additional pipe characters as part of the text", () => {
|
||||
expect(parseListNumbered("01 | Ernten | Text mit | einem Pipe")).toEqual([
|
||||
{ number: "01", title: "Ernten", text: "Text mit | einem Pipe" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("a line with only a number gets empty title and text", () => {
|
||||
expect(parseListNumbered("01")).toEqual([{ number: "01", title: "", text: "" }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseSections", () => {
|
||||
test("splits multiple ## headings into separate sections", () => {
|
||||
const text = "## Erste Sektion\n\nAbsatz eins.\n\n## Zweite Sektion\n\nAbsatz zwei.";
|
||||
expect(parseSections(text)).toEqual([
|
||||
{ heading: "Erste Sektion", paragraphs: ["Absatz eins."] },
|
||||
{ heading: "Zweite Sektion", paragraphs: ["Absatz zwei."] },
|
||||
]);
|
||||
});
|
||||
|
||||
test("keeps multiple paragraphs within one section, split on blank lines", () => {
|
||||
const text = "## Sektion\n\nErster Absatz.\n\nZweiter Absatz.";
|
||||
expect(parseSections(text)).toEqual([
|
||||
{ heading: "Sektion", paragraphs: ["Erster Absatz.", "Zweiter Absatz."] },
|
||||
]);
|
||||
});
|
||||
|
||||
test("a section with no body text gets an empty paragraphs array", () => {
|
||||
expect(parseSections("## Nur eine Ueberschrift")).toEqual([
|
||||
{ heading: "Nur eine Ueberschrift", paragraphs: [] },
|
||||
]);
|
||||
});
|
||||
|
||||
test("returns an empty array for empty input", () => {
|
||||
expect(parseSections("")).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user