Return empty string instead of undefined from getFileName on not-found

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 14:20:21 +08:00
parent a7e3a2cdce
commit 57214586a8
2 changed files with 3 additions and 2 deletions

View File

@@ -78,6 +78,7 @@ export const useCompareStore = defineStore("compareStore", {
} catch (error) { } catch (error) {
apiError(error, "Failed to load the Compare's file name."); apiError(error, "Failed to load the Compare's file name.");
} }
return "";
}, },
}, },
}); });

View File

@@ -93,14 +93,14 @@ describe("compareStore", () => {
expect(result).toBe("file1.csv"); expect(result).toBe("file1.csv");
}); });
it("returns undefined for non-existent id", async () => { it("returns empty string for non-existent id", async () => {
mockGet.mockResolvedValue({ mockGet.mockResolvedValue({
data: [{ id: 1, name: "file1.csv" }], data: [{ id: 1, name: "file1.csv" }],
}); });
const result = await store.getFileName(99); const result = await store.getFileName(99);
expect(result).toBeUndefined(); expect(result).toBe("");
}); });
}); });
}); });