mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 02:22:06 +00:00
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
mapTeamMemberDetail,
|
|
mapTeamMemberListItem,
|
|
} from "@/domain/team-members/mappers/team-member-mapper";
|
|
|
|
describe("mapTeamMemberListItem", () => {
|
|
it("maps the existing User list response and derives inactive state", () => {
|
|
expect(
|
|
mapTeamMemberListItem({
|
|
Id: "u1",
|
|
Name: "Alex Smith",
|
|
RoleName: "Dispatcher",
|
|
Locations: "Central",
|
|
Email: "alex@example.com",
|
|
Status: "Inactive",
|
|
IsAccountOwner: true,
|
|
}),
|
|
).toEqual({
|
|
id: "u1",
|
|
name: "Alex Smith",
|
|
role: "Dispatcher",
|
|
serviceArea: "Central",
|
|
phone: "",
|
|
email: "alex@example.com",
|
|
color: "",
|
|
status: "Inactive",
|
|
isAccountOwner: true,
|
|
pendingRegistration: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("mapTeamMemberDetail", () => {
|
|
it("maps service areas and the full permission summary", () => {
|
|
expect(
|
|
mapTeamMemberDetail({
|
|
Id: "u1",
|
|
Name: "Taylor",
|
|
Role: "Scheduler",
|
|
Status: "Active",
|
|
ServiceAreas: ["Central", "West"],
|
|
Permissions: [
|
|
{ PermissionKey: "createSites", OverrideState: 2, IsGranted: false },
|
|
{ PermissionKey: "editSites", OverrideState: "Allow", IsGranted: true },
|
|
],
|
|
}),
|
|
).toMatchObject({
|
|
id: "u1",
|
|
serviceAreas: ["Central", "West"],
|
|
permissions: [
|
|
{ permissionKey: "createSites", overrideState: 2, isGranted: false },
|
|
{ permissionKey: "editSites", overrideState: 1, isGranted: true },
|
|
],
|
|
});
|
|
});
|
|
|
|
it("keeps the invite email result only when the update reported one", () => {
|
|
expect(mapTeamMemberDetail({ id: "u1", inviteEmailSent: false }).inviteEmailSent).toBe(false);
|
|
expect(mapTeamMemberDetail({ Id: "u1", InviteEmailSent: true }).inviteEmailSent).toBe(true);
|
|
expect(mapTeamMemberDetail({ id: "u1" })).not.toHaveProperty("inviteEmailSent");
|
|
});
|
|
});
|