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,49 @@
|
||||
import { describe, test, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
|
||||
// insensitiveContains/insensitiveEquals read DATABASE_PROVIDER once at module
|
||||
// load (not per call, see prisma-search.ts) — vi.resetModules() + a fresh
|
||||
// dynamic import per test is required to observe both branches.
|
||||
const originalProvider = process.env.DATABASE_PROVIDER;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (originalProvider === undefined) delete process.env.DATABASE_PROVIDER;
|
||||
else process.env.DATABASE_PROVIDER = originalProvider;
|
||||
});
|
||||
|
||||
describe("insensitiveContains", () => {
|
||||
test("adds mode: insensitive for the postgresql provider", async () => {
|
||||
process.env.DATABASE_PROVIDER = "postgresql";
|
||||
const { insensitiveContains } = await import("./prisma-search");
|
||||
expect(insensitiveContains("mild")).toEqual({ contains: "mild", mode: "insensitive" });
|
||||
});
|
||||
|
||||
test("adds mode: insensitive when DATABASE_PROVIDER is unset (default)", async () => {
|
||||
delete process.env.DATABASE_PROVIDER;
|
||||
const { insensitiveContains } = await import("./prisma-search");
|
||||
expect(insensitiveContains("mild")).toEqual({ contains: "mild", mode: "insensitive" });
|
||||
});
|
||||
|
||||
test("omits mode for the mysql provider", async () => {
|
||||
process.env.DATABASE_PROVIDER = "mysql";
|
||||
const { insensitiveContains } = await import("./prisma-search");
|
||||
expect(insensitiveContains("mild")).toEqual({ contains: "mild" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("insensitiveEquals", () => {
|
||||
test("adds mode: insensitive for the postgresql provider", async () => {
|
||||
process.env.DATABASE_PROVIDER = "postgresql";
|
||||
const { insensitiveEquals } = await import("./prisma-search");
|
||||
expect(insensitiveEquals("mild")).toEqual({ equals: "mild", mode: "insensitive" });
|
||||
});
|
||||
|
||||
test("omits mode for the mysql provider", async () => {
|
||||
process.env.DATABASE_PROVIDER = "mysql";
|
||||
const { insensitiveEquals } = await import("./prisma-search");
|
||||
expect(insensitiveEquals("mild")).toEqual({ equals: "mild" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user