Rollen Chunk 4: Benutzerkonto, Abmelde-Icon und fremde Einstellungen
This commit is contained in:
1 parent
6fb252c379
commit
452f38e9cd
1 file changed
+39
@@ -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" }),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user