feat: filter exports by spread thresholds

This commit is contained in:
wxs
2026-06-29 16:11:52 +08:00
parent 121977fd0d
commit 9eb1fe43cc
8 changed files with 803 additions and 24 deletions
+46
View File
@@ -5,6 +5,7 @@ import {
buildSpreadInfoUrl,
createSpreadInfoClient,
DEFAULT_SPREAD_INFO_CONFIGS,
matchesSpreadThresholds,
mapSpreadInfoResponse
} from "../src/content/market/spread-info";
@@ -165,4 +166,49 @@ describe("spread-info", () => {
})
);
});
test("matches thresholds using display values and requires every filled threshold", () => {
expect(
matchesSpreadThresholds(
{
averageDuration: "56",
finishRate: "28.24%",
interactionRate: "4.02%",
playMedian: "10913233"
},
{
averageDuration: 50,
finishRate: 28,
interactionRate: 4,
playMedian: 10000000
}
)
).toBe(true);
expect(
matchesSpreadThresholds(
{
averageDuration: "56",
finishRate: "28.24%",
interactionRate: "4.02%",
playMedian: "10913233"
},
{
averageDuration: 57
}
)
).toBe(false);
expect(
matchesSpreadThresholds(
{
finishRate: "28.24%"
},
{
finishRate: 20,
interactionRate: 1
}
)
).toBe(false);
});
});