forked from Yara724/api
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
|
|
import { ClaimStatus } from "src/Types&Enums/claim-request-management/claimStatus.enum";
|
|
import { ClaimWorkflowStep } from "src/Types&Enums/claim-request-management/claim-workflow-steps.enum";
|
|
import { ClaimRequestManagementService } from "./claim-request-management.service";
|
|
|
|
describe("owner insurer approval without branch selection", () => {
|
|
it("records a final rejection when no branchId is supplied", async () => {
|
|
const service = Object.create(
|
|
ClaimRequestManagementService.prototype,
|
|
) as ClaimRequestManagementService;
|
|
const findByIdAndUpdate = jest.fn().mockResolvedValue(undefined);
|
|
|
|
(service as any).claimCaseDbService = {
|
|
findById: jest.fn().mockResolvedValue({
|
|
_id: "507f1f77bcf86cd799439011",
|
|
status: ClaimCaseStatus.INSURER_REVIEW_AWAITING_OWNER_SIGN,
|
|
claimStatus: ClaimStatus.APPROVED,
|
|
workflow: { currentStep: ClaimWorkflowStep.INSURER_REVIEW },
|
|
owner: { fullName: "مالک تست", clientId: "client-id" },
|
|
evaluation: {
|
|
damageExpertReply: { submittedAt: new Date(), parts: [] },
|
|
},
|
|
}),
|
|
findByIdAndUpdate,
|
|
};
|
|
(service as any).resolveClaimEffectiveUserId = jest
|
|
.fn()
|
|
.mockResolvedValue("507f1f77bcf86cd799439012");
|
|
(service as any).assertEffectiveUserIsDamagedPartyOnClaim = jest
|
|
.fn()
|
|
.mockResolvedValue(undefined);
|
|
(service as any).claimSignDbService = {
|
|
create: jest
|
|
.fn()
|
|
.mockResolvedValue({ _id: "507f1f77bcf86cd799439013" }),
|
|
};
|
|
|
|
await expect(
|
|
service.submitOwnerInsurerApprovalSignV2(
|
|
"507f1f77bcf86cd799439011",
|
|
false,
|
|
{ filename: "sign.png", path: "/tmp/sign.png" } as Express.Multer.File,
|
|
"507f1f77bcf86cd799439012",
|
|
),
|
|
).resolves.toMatchObject({
|
|
accepted: false,
|
|
phase: "FINAL_APPROVAL",
|
|
status: ClaimCaseStatus.REJECTED,
|
|
});
|
|
|
|
expect(findByIdAndUpdate).toHaveBeenCalledWith(
|
|
"507f1f77bcf86cd799439011",
|
|
expect.objectContaining({
|
|
$set: expect.objectContaining({
|
|
"evaluation.ownerInsurerApproval": expect.not.objectContaining({
|
|
branchId: expect.anything(),
|
|
}),
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
});
|