Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
21 lines
1.0 KiB
TypeScript
21 lines
1.0 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({ callMobileApi: vi.fn(), getToken: vi.fn() }));
|
|
vi.mock("@/app/lib/server/mobileApi", () => ({ callMobileApi: mocks.callMobileApi }));
|
|
vi.mock("@/app/lib/server/session", () => ({ getToken: mocks.getToken }));
|
|
|
|
import { POST } from "./route";
|
|
|
|
beforeEach(() => {
|
|
mocks.callMobileApi.mockReset().mockResolvedValue({ ok: true, data: {} });
|
|
mocks.getToken.mockReset().mockResolvedValue("jwt");
|
|
});
|
|
|
|
describe("/api/login-security unlock", () => {
|
|
it("POST forwards the companyId query to the upstream URL", async () => {
|
|
const req = new Request("http://localhost/api/login-security/locked/a/unlock?companyId=2", { method: "POST", body: "{}", headers: { "Content-Type": "application/json" } });
|
|
await POST(req as unknown as Parameters<typeof POST>[0], { params: Promise.resolve({ path: ["locked", "a", "unlock"] }) });
|
|
expect(mocks.callMobileApi.mock.calls[0][0]).toBe("/api/admin/login-security/locked/a/unlock?companyId=2");
|
|
});
|
|
});
|