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.
30 lines
923 B
30 lines
923 B
import { describe, expect, it } from "vitest";
|
|
import { buildImportIdempotencyKey } from "@/utils/idempotency-client";
|
|
|
|
describe("buildImportIdempotencyKey", () => {
|
|
it("stays within 128 chars even with hundreds of row indexes", () => {
|
|
const key = buildImportIdempotencyKey({
|
|
mailId: "99",
|
|
instructionId: "forecast-body_segment-5-派送单请查收",
|
|
containerNo: "ZCSU6581068",
|
|
rowIndexes: Array.from({ length: 290 }, (_, i) => i),
|
|
});
|
|
expect(key.length).toBeLessThanOrEqual(128);
|
|
expect(key.startsWith("99:")).toBe(true);
|
|
});
|
|
|
|
it("changes when the selected rows change", () => {
|
|
const a = buildImportIdempotencyKey({
|
|
mailId: "1",
|
|
containerNo: "ABCD1234567",
|
|
rowIndexes: [0, 1],
|
|
});
|
|
const b = buildImportIdempotencyKey({
|
|
mailId: "1",
|
|
containerNo: "ABCD1234567",
|
|
rowIndexes: [0, 2],
|
|
});
|
|
expect(a).not.toBe(b);
|
|
});
|
|
});
|