forked from Yara724/api
67 lines
2.3 KiB
TypeScript
67 lines
2.3 KiB
TypeScript
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
|
|
import { CaseStatus } from "src/Types&Enums/blame-request-management/caseStatus.enum";
|
|
import { ExpertBlameService } from "./expert-blame.service";
|
|
|
|
describe("ExpertBlameService participant detail contract", () => {
|
|
it("returns normalized participants and their role assignments from the blame party", async () => {
|
|
const service = new (ExpertBlameService as any)(
|
|
...new Array(13).fill(undefined),
|
|
) as any;
|
|
const expertId = "66ec0e480e321873c0900001";
|
|
|
|
service.expireBlameCaseWorkflowLockV2IfStale = jest
|
|
.fn()
|
|
.mockResolvedValue(undefined);
|
|
service.blameRequestDbService = {
|
|
findByIdWithoutHistory: jest.fn().mockResolvedValue({
|
|
_id: "66ec0e480e321873c0900002",
|
|
type: BlameRequestType.THIRD_PARTY,
|
|
status: CaseStatus.WAITING_FOR_EXPERT,
|
|
expertInitiated: true,
|
|
initiatedByFieldExpertId: expertId,
|
|
workflow: {},
|
|
parties: [
|
|
{
|
|
role: "FIRST",
|
|
person: { fullName: "Legacy Party Name" },
|
|
participants: [
|
|
{
|
|
participantId: "PERSON_1",
|
|
nationalCode: "0012345678",
|
|
birthday: "1370/01/01",
|
|
unknown: true,
|
|
},
|
|
],
|
|
participantRoles: {
|
|
driver: "PERSON_1",
|
|
vehicleOwner: "PERSON_1",
|
|
thirdPartyPolicyholder: "PERSON_1",
|
|
},
|
|
vehicle: { inquiry: { raw: { large: true } } },
|
|
},
|
|
],
|
|
createdAt: new Date("2026-09-19T00:00:00.000Z"),
|
|
updatedAt: new Date("2026-09-19T00:00:00.000Z"),
|
|
}),
|
|
};
|
|
|
|
const result = await service.findOneV2("blame-1", { sub: expertId });
|
|
const party = (result.parties as any[])[0];
|
|
|
|
expect(party.participants).toEqual([
|
|
{
|
|
participantId: "PERSON_1",
|
|
nationalCode: "0012345678",
|
|
birthday: "1370/01/01",
|
|
},
|
|
]);
|
|
expect(party.participantRoles).toEqual({
|
|
driver: "PERSON_1",
|
|
vehicleOwner: "PERSON_1",
|
|
thirdPartyPolicyholder: "PERSON_1",
|
|
});
|
|
expect(party.person.fullName).toBe("Legacy Party Name");
|
|
expect(party.vehicle.inquiry).toBeUndefined();
|
|
});
|
|
});
|