Rollen Chunk 5b: Auth-Routen initialisieren frische Datenbanken
This commit is contained in:
1 parent
6133dd9089
commit
ccb71ea5d8
1 file changed
+29
@@ -139,3 +139,32 @@ describe("Benutzerkonto (Chunk 4)", () => {
|
||||
expect(row?.email).toBe("neu@example.org");
|
||||
});
|
||||
});
|
||||
|
||||
describe("frische Datenbank (Chunk 5)", () => {
|
||||
test("Erstanlage ohne vorheriges Setup", async () => {
|
||||
const { mkdtempSync, rmSync } = await import("node:fs");
|
||||
const { tmpdir } = await import("node:os");
|
||||
const { join } = await import("node:path");
|
||||
const { closeDb } = await import("@/lib/db");
|
||||
const dir = mkdtempSync(join(tmpdir(), "muz-frisch-"));
|
||||
closeDb();
|
||||
process.env.DATA_DIR = dir;
|
||||
try {
|
||||
const response = await POST(
|
||||
new Request("http://localhost/api/auth/sign-up/email", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
name: "Frisch",
|
||||
email: "frisch@example.org",
|
||||
password: "geheim-geheim!",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(response.status).toBe(200);
|
||||
} finally {
|
||||
closeDb();
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user