mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 11:33:22 +00:00
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { API_PATHS } from "@/api/api-paths";
|
|
|
|
const apiGet = vi.fn();
|
|
const apiPost = vi.fn();
|
|
|
|
vi.mock("@/api/api", () => ({
|
|
apiGet: (...args: unknown[]) => apiGet(...args),
|
|
apiPost: (...args: unknown[]) => apiPost(...args),
|
|
}));
|
|
|
|
import { teamMembersApi } from "@/domain/team-members/api/team-members-api";
|
|
|
|
describe("teamMembersApi", () => {
|
|
beforeEach(() => {
|
|
apiGet.mockReset();
|
|
apiPost.mockReset();
|
|
});
|
|
|
|
it("posts the pending team member contract without invitation fields", async () => {
|
|
apiPost.mockResolvedValueOnce({
|
|
data: {
|
|
id: "u-1",
|
|
name: "Taylor Dispatcher",
|
|
role: "Dispatcher",
|
|
pendingRegistration: true,
|
|
},
|
|
});
|
|
|
|
const input = {
|
|
name: "Taylor Dispatcher",
|
|
role: "Dispatcher" as const,
|
|
color: "#F59E0B",
|
|
email: "taylor@example.com",
|
|
phone: "555-0100",
|
|
serviceAreas: ["East"],
|
|
permissionOverrides: { deleteSites: 1 as const },
|
|
};
|
|
|
|
await expect(teamMembersApi.create(input)).resolves.toMatchObject({
|
|
id: "u-1",
|
|
pendingRegistration: true,
|
|
});
|
|
expect(apiPost).toHaveBeenCalledWith(API_PATHS.teamMember.create, input);
|
|
expect(apiPost.mock.calls[0]?.[1]).not.toHaveProperty("invite");
|
|
expect(apiPost.mock.calls[0]?.[1]).not.toHaveProperty("password");
|
|
});
|
|
});
|