You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

import { describe, expect, it } from "vitest";
import {
hasFlockRegistrationOverride,
resolveFlockQuoteAccount,
} from "@/lib/flock/resolve-account";
import type { FlockQuoteInput } from "@/workers/rpa/flock/types";
function baseInput(
registration?: FlockQuoteInput["registration"],
): FlockQuoteInput {
return {
pickupDate: "07/14/2026",
pickupZip: "90001",
deliveryZip: "75201",
palletCount: 6,
totalWeightLb: 3500,
lengthIn: 48,
widthIn: 40,
heightIn: 48,
registration,
};
}
describe("hasFlockRegistrationOverride", () => {
it("空对象视为未填写", () => {
expect(hasFlockRegistrationOverride({})).toBe(false);
expect(hasFlockRegistrationOverride(undefined)).toBe(false);
});
it("任一字段有值即为自填", () => {
expect(hasFlockRegistrationOverride({ email: "a@b.com" })).toBe(true);
});
});
describe("resolveFlockQuoteAccount", () => {
it("用户邮箱覆盖系统随机", () => {
const account = resolveFlockQuoteAccount(
baseInput({ email: "user@example.com", phone: "7536407420" }),
);
expect(account.email).toBe("user@example.com");
expect(account.phone).toBe("7536407420");
expect(account.firstName.length).toBeGreaterThan(0);
});
});