43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const apiGet = vi.fn();
|
|
const apiPost = vi.fn();
|
|
const apiPatch = vi.fn();
|
|
|
|
vi.mock("./axios", () => ({
|
|
apiGet,
|
|
apiPost,
|
|
apiPatch,
|
|
}));
|
|
|
|
describe("etmf api", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("uses canonical eTMF URLs", async () => {
|
|
const { fetchEtmfTree, fetchEtmfNodeDocuments, createEtmfNode, updateEtmfNode, createEtmfDocument } = await import("./etmf");
|
|
|
|
fetchEtmfTree("study-1");
|
|
fetchEtmfNodeDocuments("node-1", { site_id: "site-1" });
|
|
createEtmfNode({ study_id: "study-1", code: "01", name: "项目管理" });
|
|
updateEtmfNode("node-1", { name: "项目管理文件" });
|
|
createEtmfDocument("node-1", {
|
|
trial_id: "study-1",
|
|
doc_no: "DOC-001",
|
|
doc_type: "Protocol",
|
|
title: "研究方案",
|
|
scope_type: "GLOBAL",
|
|
});
|
|
|
|
expect(apiGet).toHaveBeenCalledWith("/api/v1/etmf/tree", { params: { study_id: "study-1" } });
|
|
expect(apiGet).toHaveBeenCalledWith("/api/v1/etmf/nodes/node-1/documents", { params: { site_id: "site-1" } });
|
|
expect(apiPost).toHaveBeenCalledWith("/api/v1/etmf/nodes", { study_id: "study-1", code: "01", name: "项目管理" });
|
|
expect(apiPatch).toHaveBeenCalledWith("/api/v1/etmf/nodes/node-1", { name: "项目管理文件" });
|
|
expect(apiPost).toHaveBeenCalledWith(
|
|
"/api/v1/etmf/nodes/node-1/documents",
|
|
expect.objectContaining({ doc_no: "DOC-001" })
|
|
);
|
|
});
|
|
});
|