From 8ba17871770697735a27889dac6cf2afe44151f1 Mon Sep 17 00:00:00 2001 From: wxs Date: Fri, 17 Jul 2026 12:13:59 +0800 Subject: [PATCH] test: cover empty favorite author ids --- tests/favorites-import.test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/favorites-import.test.ts b/tests/favorites-import.test.ts index 2db2790..35d4d5b 100644 --- a/tests/favorites-import.test.ts +++ b/tests/favorites-import.test.ts @@ -53,6 +53,36 @@ describe("favorites-import", () => { ]); }); + test("excludes empty author ids while keeping valid authors in first-occurrence order", () => { + expect( + toFavoriteMarketRecords([ + { + authorId: "", + authorName: "无效达人", + savedAt: "2026-07-17T00:00:00.000Z" + }, + { + authorId: "author-2", + authorName: "达人B", + savedAt: "2026-07-17T00:00:01.000Z" + }, + { + authorId: "author-1", + authorName: "达人A", + savedAt: "2026-07-17T00:00:02.000Z" + }, + { + authorId: "author-2", + authorName: "达人B更新", + savedAt: "2026-07-17T00:00:03.000Z" + } + ]) + ).toEqual([ + { authorId: "author-2", authorName: "达人B", status: "idle" }, + { authorId: "author-1", authorName: "达人A", status: "idle" } + ]); + }); + test("returns only the minimal idle market record fields", () => { const [record] = toFavoriteMarketRecords([ {