fix: apply quota point conversion

This commit is contained in:
Alex committed 2026-11-09 09:56:06 +08:00
1 parent 2553e482a9
commit ad66ae5f10
12 files changed
+205 -25

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import { describe, expect, test } from "bun:test";
import { pointsToQuota, quotaToPoints, QUOTA_PER_POINT } from "../src/quota";
describe("quota mapping", () => {
test("uses 5000 quota units for one point", () => {
expect(QUOTA_PER_POINT).toBe(5000);
expect(pointsToQuota(1)).toBe(5000);
expect(pointsToQuota(520)).toBe(2_600_000);
});
test("rounds displayed points upward", () => {
expect(quotaToPoints(0)).toBe(0);
expect(quotaToPoints(1)).toBe(1);
expect(quotaToPoints(5000)).toBe(1);
expect(quotaToPoints(5001)).toBe(2);
});
test("rejects invalid point values", () => {
expect(() => pointsToQuota(-1)).toThrow();
expect(() => pointsToQuota(1.5)).toThrow();
expect(() => pointsToQuota(Number.MAX_SAFE_INTEGER)).toThrow();
});
});