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:
@@ -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 "";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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("");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user