forked from Yara724/api
YARA-1257, YARA-1272, YARA-985
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
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(),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user