forked from Yara724/api
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { Types } from "mongoose";
|
|
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
|
|
import { RoleEnum } from "src/Types&Enums/role.enum";
|
|
import { RequestManagementService } from "./request-management.service";
|
|
|
|
describe("RequestManagementService V5 FileMaker approval", () => {
|
|
it("completes the claim without notifying the owner for a final signature", async () => {
|
|
const fileMakerId = new Types.ObjectId();
|
|
const claimId = new Types.ObjectId();
|
|
const claimCaseDbService = {
|
|
findById: jest.fn().mockResolvedValue({
|
|
_id: claimId,
|
|
publicId: "CLM-V5",
|
|
status: ClaimCaseStatus.WAITING_FOR_FILE_MAKER_APPROVAL,
|
|
requiresFileMakerApproval: true,
|
|
fileMakerApprovalActorId: fileMakerId,
|
|
}),
|
|
findByIdAndUpdate: jest.fn().mockResolvedValue({}),
|
|
};
|
|
const service = new (RequestManagementService as any)(
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
claimCaseDbService,
|
|
) as RequestManagementService;
|
|
|
|
const result = await service.fileMakerApproveV5(
|
|
{ sub: String(fileMakerId), role: RoleEnum.FILE_MAKER },
|
|
String(claimId),
|
|
);
|
|
|
|
expect(result.status).toBe(ClaimCaseStatus.COMPLETED);
|
|
expect(result.message).toContain("Submit it to Fanavaran manually");
|
|
expect(claimCaseDbService.findByIdAndUpdate).toHaveBeenCalledWith(
|
|
String(claimId),
|
|
expect.objectContaining({
|
|
$set: expect.objectContaining({
|
|
status: ClaimCaseStatus.COMPLETED,
|
|
requiresFileMakerApproval: false,
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
});
|