55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import { createBatchPayload } from "../src/content/market/batch-payload";
|
|
|
|
describe("batch-payload", () => {
|
|
test("builds a batch id from the user id and timestamp", () => {
|
|
const payload = createBatchPayload({
|
|
authState: {
|
|
isAuthenticated: true,
|
|
resource: "https://talent-search.intelligrow.cn",
|
|
userInfo: {
|
|
name: "王少卿",
|
|
sub: "p7pdhhtde8kj"
|
|
}
|
|
},
|
|
batchName: "618达人筛选第一批",
|
|
createdAt: "2026-04-22T12:30:00.000Z",
|
|
records: [
|
|
{ authorId: "111", authorName: "达人A", status: "success" },
|
|
{ authorId: "222", authorName: "达人B", status: "success" }
|
|
]
|
|
});
|
|
|
|
expect(payload).toEqual({
|
|
authors: [
|
|
{ authorId: "111", authorName: "达人A" },
|
|
{ authorId: "222", authorName: "达人B" }
|
|
],
|
|
batchId: "p7pdhhtde8kj-2026-04-22T12:30:00.000Z",
|
|
batchName: "618达人筛选第一批",
|
|
createdAt: "2026-04-22T12:30:00.000Z",
|
|
creatorName: "王少卿",
|
|
logtoUserId: "p7pdhhtde8kj",
|
|
resource: "https://talent-search.intelligrow.cn"
|
|
});
|
|
});
|
|
|
|
test("throws when the user id is unavailable", () => {
|
|
expect(() =>
|
|
createBatchPayload({
|
|
authState: {
|
|
isAuthenticated: true,
|
|
resource: "https://talent-search.intelligrow.cn",
|
|
userInfo: {
|
|
name: "王少卿"
|
|
}
|
|
},
|
|
batchName: "批次A",
|
|
createdAt: "2026-04-22T12:30:00.000Z",
|
|
records: [{ authorId: "111", authorName: "达人A", status: "success" }]
|
|
})
|
|
).toThrow(/user/i);
|
|
});
|
|
});
|