import { beforeEach, describe, expect, it, vi } from "vitest"; const apiGet = vi.fn(); const apiPost = vi.fn(); const apiDelete = vi.fn(); vi.mock("./axios", () => ({ apiGet, apiPost, apiDelete, })); describe("attachments api", () => { beforeEach(() => { vi.clearAllMocks(); }); it("uses canonical collection URLs with trailing slash", async () => { const { fetchAttachments, uploadAttachment } = await import("./attachments"); const file = new File(["x"], "x.txt", { type: "text/plain" }); fetchAttachments("study-1", "startup_feasibility", "entity-1"); uploadAttachment("study-1", "startup_feasibility", "entity-1", file); expect(apiGet).toHaveBeenCalledWith("/api/v1/studies/study-1/startup_feasibility/entity-1/attachments/"); expect(apiPost).toHaveBeenCalledWith( "/api/v1/studies/study-1/startup_feasibility/entity-1/attachments/", expect.any(FormData), expect.objectContaining({ headers: { "Content-Type": "multipart/form-data" } }) ); }); });