forked from Yara724/api
Read saved document status from maps and plain objects, acknowledge verified document retries without replacing stored images, and preserve upload authorization and resend behavior. Lower the car-body narrative minimum to 30 characters with Persian errors and boundary regression coverage.
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { RequestManagementService } from "./request-management.service";
|
|
|
|
describe("RequestManagementService CAR_BODY insurer client", () => {
|
|
const previousClientId = process.env.CLIENT_ID;
|
|
|
|
afterEach(() => {
|
|
if (previousClientId === undefined) delete process.env.CLIENT_ID;
|
|
else process.env.CLIENT_ID = previousClientId;
|
|
});
|
|
|
|
it("uses the deployment insurer when the processed body lookup has no company id", async () => {
|
|
process.env.CLIENT_ID = "8";
|
|
const service = Object.create(RequestManagementService.prototype) as any;
|
|
service.clientService = {
|
|
findOne: jest.fn().mockResolvedValue({ _id: "body-client-8" }),
|
|
};
|
|
|
|
await expect(
|
|
service.resolveCarBodyPolicyClientId({ companyId: null }),
|
|
).resolves.toBe("body-client-8");
|
|
expect(service.clientService.findOne).toHaveBeenCalledWith({
|
|
clientCode: 8,
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
describe("CAR_BODY description minimum", () => {
|
|
const service = Object.create(RequestManagementService.prototype) as any;
|
|
|
|
it.each([30, 31, 99, 100])("accepts %s trimmed characters", length => {
|
|
expect(() => service.assertCarBodyDescriptionMinimum("CAR_BODY", ` ${"ش".repeat(length)} `)).not.toThrow();
|
|
});
|
|
|
|
it.each([undefined, "", " ", "ش".repeat(29), ` ${"ش".repeat(29)} `])("rejects a short description with a Persian 30-character message", description => {
|
|
expect(() => service.assertCarBodyDescriptionMinimum("CAR_BODY", description)).toThrow("شرح حادثه باید حداقل ۳۰ کاراکتر باشد.");
|
|
});
|
|
|
|
it("preserves optional third-party descriptions", () => {
|
|
expect(() => service.assertCarBodyDescriptionMinimum("THIRD_PARTY", "")).not.toThrow();
|
|
});
|
|
});
|