Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
29 lines
1.3 KiB
TypeScript
29 lines
1.3 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({ apiGet: vi.fn(), apiPost: vi.fn(), apiDelete: vi.fn() }));
|
|
vi.mock("@/app/lib/clientApi", () => mocks);
|
|
|
|
import { addGuests, getAttendance, getCheckin, listGuests, removeGuest, sendInvites } from "./adminGuests";
|
|
|
|
beforeEach(() => Object.values(mocks).forEach((m) => m.mockReset().mockResolvedValue({})));
|
|
|
|
describe("adminGuests service", () => {
|
|
it("calls the event guest proxies", async () => {
|
|
const g = [{ name: "A", mobile: "", email: "a@x.my", companyName: "" }];
|
|
await listGuests("e 1");
|
|
await addGuests("e 1", g, true);
|
|
await addGuests("e 1", g, false);
|
|
await removeGuest("e 1", 7);
|
|
await sendInvites("e 1", { guestIds: [7] });
|
|
await getCheckin("e 1");
|
|
await getAttendance("e 1");
|
|
expect(mocks.apiGet.mock.calls).toEqual([["/api/events/e%201/guests"], ["/api/events/e%201/checkin"], ["/api/events/e%201/attendance"]]);
|
|
expect(mocks.apiPost.mock.calls).toEqual([
|
|
["/api/events/e%201/guests?preview=true", { guests: g }],
|
|
["/api/events/e%201/guests", { guests: g }],
|
|
["/api/events/e%201/guests/send", { guestIds: [7] }],
|
|
]);
|
|
expect(mocks.apiDelete.mock.calls).toEqual([["/api/events/e%201/guests/7"]]);
|
|
});
|
|
});
|