Rollen Chunk 4: Benutzerkonto, Abmelde-Icon und fremde Einstellungen
Docker Image / test (push) Canceled after 0s
Docker Image / image (push) Canceled after 0s

This commit is contained in:
loki committed 2026-10-11 19:14:07 +02:00
1 parent 6fb252c379
commit 452f38e9cd
1 file changed
+39
+39
View File
@@ -103,3 +103,42 @@ describe("auth-client SSO", () => {
);
});
});
describe("auth-client Konto", () => {
test("changePassword wechselt das Passwort", async () => {
const { changePassword } = await import("./auth-client");
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify({ status: true }), {
status: 200,
headers: { "content-type": "application/json" },
}),
);
vi.stubGlobal("fetch", fetchMock);
await changePassword("alt-geheim!", "neu-geheim-1!");
expect(fetchMock).toHaveBeenCalledWith(
"/api/auth/change-password",
expect.objectContaining({ method: "POST" }),
);
const [, init] = fetchMock.mock.calls[0] as [string, { body: string }];
expect(JSON.parse(init.body)).toEqual({
currentPassword: "alt-geheim!",
newPassword: "neu-geheim-1!",
});
});
test("changeEmail wechselt die Adresse", async () => {
const { changeEmail } = await import("./auth-client");
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify({ status: true }), {
status: 200,
headers: { "content-type": "application/json" },
}),
);
vi.stubGlobal("fetch", fetchMock);
await changeEmail("neu@example.org");
expect(fetchMock).toHaveBeenCalledWith(
"/api/auth/change-email",
expect.objectContaining({ method: "POST" }),
);
});
});