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.
33 lines
1011 B
TypeScript
33 lines
1011 B
TypeScript
import { describe, test, expect } from "vitest";
|
|
import { asStringArray } from "./json-array";
|
|
|
|
describe("asStringArray", () => {
|
|
test("passes an array of strings through unchanged", () => {
|
|
expect(asStringArray(["mild", "floral"])).toEqual(["mild", "floral"]);
|
|
});
|
|
|
|
test("returns an empty array for an empty array", () => {
|
|
expect(asStringArray([])).toEqual([]);
|
|
});
|
|
|
|
test("drops non-string entries from a mixed array", () => {
|
|
expect(asStringArray(["mild", 5, null, "floral", { a: 1 }])).toEqual(["mild", "floral"]);
|
|
});
|
|
|
|
test("returns an empty array for null", () => {
|
|
expect(asStringArray(null)).toEqual([]);
|
|
});
|
|
|
|
test("returns an empty array for undefined", () => {
|
|
expect(asStringArray(undefined)).toEqual([]);
|
|
});
|
|
|
|
test("returns an empty array for a plain object", () => {
|
|
expect(asStringArray({ tasteTags: ["mild"] })).toEqual([]);
|
|
});
|
|
|
|
test("returns an empty array for a scalar string", () => {
|
|
expect(asStringArray("mild")).toEqual([]);
|
|
});
|
|
});
|