see comments

This commit is contained in:
Rajpreet0 2026-04-27 20:42:41 +02:00
parent 51e6f4cd2a
commit e2a419a343
3 changed files with 12 additions and 7 deletions

View file

@ -70,12 +70,14 @@ describe("POST /api/upload/avatar", () => {
const res = await POST(makeRequest(null, "valid-token"));
expect(res.status).toBe(400);
const data = await res.json();
expect(data.error).toContain("Token");
expect(data.error).toContain("Datei und Token erforderlich");
});
it("gibt 400 zurück wenn Token fehlt", async () => {
const res = await POST(makeRequest(makeImageFile(), null));
expect(res.status).toBe(400);
const data = await res.json();
expect(data.error).toContain("Datei und Token erforderlich");
});
it("gibt 401 zurück bei ungültigem Token", async () => {

View file

@ -1,6 +1,12 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { renderHook, act } from "@testing-library/react";
const { mockRouterPush, mockSetUser, mockSupabaseSignIn } = vi.hoisted(() => ({
mockRouterPush: vi.fn(),
mockSetUser: vi.fn(),
mockSupabaseSignIn: vi.fn(),
}));
vi.mock("next/navigation", () => ({
useRouter: () => ({ push: mockRouterPush }),
}));
@ -18,10 +24,6 @@ vi.mock("sonner", () => ({
toast: { success: vi.fn(), error: vi.fn() },
}));
const mockRouterPush = vi.fn();
const mockSetUser = vi.fn();
const mockSupabaseSignIn = vi.fn();
import { useAuth } from "@/src/hooks/useAuth";
beforeEach(() => {