24 lines
788 B
TypeScript
24 lines
788 B
TypeScript
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();
|
|
});
|
|
});
|