Allow partial market rates in CSV export

This commit is contained in:
2026-04-22 19:22:10 +08:00
parent c7ae2fbfcb
commit 2f77199920
5 changed files with 138 additions and 16 deletions
+17 -4
View File
@@ -33,12 +33,10 @@ describe("market-api-client", () => {
});
});
test("returns a missing-rate failure when the payload omits a required field", () => {
test("returns a missing-rate failure when the payload omits both rate fields", () => {
expect(
mapAuthorAseInfoResponse({
data: {
avg_search_after_view_rate: "<0.02%"
}
data: {}
})
).toMatchObject({
success: false,
@@ -46,6 +44,21 @@ describe("market-api-client", () => {
});
});
test("maps a partially populated payload into partial rates", () => {
expect(
mapAuthorAseInfoResponse({
data: {
personal_avg_search_after_view_rate: "0.02 - 0.1%"
}
})
).toMatchObject({
success: true,
rates: {
personalVideoAfterSearchRate: "0.02% - 0.1%"
}
});
});
test("returns a request-failed result for non-ok responses", async () => {
const client = createMarketApiClient({
fetchImpl: async () => ({