| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | 2 | |
| 3 | | import { buildDayColumns, niceScale } from "./UsageProviderChart"; |
| 3 | import { buildPeriodColumns, niceScale } from "./UsageProviderChart"; |
| 4 | 4 | import { providersWithUsage } from "./usageProviders"; |
| 5 | 5 | |
| 6 | 6 | describe("niceScale", () => { |
| ... | ... | @@ -41,7 +41,7 @@ describe("niceScale", () => { |
| 41 | 41 | }); |
| 42 | 42 | }); |
| 43 | 43 | |
| 44 | | describe("buildDayColumns", () => { |
| 44 | describe("buildPeriodColumns", () => { |
| 45 | 45 | const days = ["2026-08-01", "2026-08-02", "2026-08-03"]; |
| 46 | 46 | const byDay = new Map([ |
| 47 | 47 | [ |
| ... | ... | @@ -69,11 +69,13 @@ describe("buildDayColumns", () => { |
| 69 | 69 | ]); |
| 70 | 70 | |
| 71 | 71 | it("plots each day on its own", () => { |
| 72 | | expect(buildDayColumns(days, byDay, "cost").map((column) => column.total)).toEqual([30, 0, 5]); |
| 72 | expect(buildPeriodColumns(days, byDay, "cost").map((column) => column.total)).toEqual([ |
| 73 | 30, 0, 5, |
| 74 | ]); |
| 73 | 75 | }); |
| 74 | 76 | |
| 75 | 77 | it("reads the requested metric", () => { |
| 76 | | expect(buildDayColumns(days, byDay, "tokens").map((column) => column.total)).toEqual([ |
| 78 | expect(buildPeriodColumns(days, byDay, "tokens").map((column) => column.total)).toEqual([ |
| 77 | 79 | 300, 0, 50, |
| 78 | 80 | ]); |
| 79 | 81 | }); |
| ... | ... | @@ -81,7 +83,7 @@ describe("buildDayColumns", () => { |
| 81 | 83 | it("keeps band values absolute rather than cumulative", () => { |
| 82 | 84 | // Regression: the bands were once stack offsets, which drew Claude Code |
| 83 | 85 | // permanently above Codex regardless of which provider spent more. |
| 84 | | const [first] = buildDayColumns(days, byDay, "cost"); |
| 86 | const [first] = buildPeriodColumns(days, byDay, "cost"); |
| 85 | 87 | |
| 86 | 88 | expect(first?.bands).toEqual([ |
| 87 | 89 | { provider: "codex", value: 10 }, |
| ... | ... | @@ -91,7 +93,7 @@ describe("buildDayColumns", () => { |
| 91 | 93 | }); |
| 92 | 94 | |
| 93 | 95 | it("reports the total as the sum of its bands", () => { |
| 94 | | for (const column of buildDayColumns(days, byDay, "cost")) { |
| 96 | for (const column of buildPeriodColumns(days, byDay, "cost")) { |
| 95 | 97 | const sum = column.bands.reduce((running, band) => running + band.value, 0); |
| 96 | 98 | expect(column.total).toBeCloseTo(sum, 9); |
| 97 | 99 | } |
| ... | ... | @@ -125,7 +127,7 @@ describe("hourly chart columns", () => { |
| 125 | 127 | ]); |
| 126 | 128 | |
| 127 | 129 | expect( |
| 128 | | buildDayColumns( |
| 130 | buildPeriodColumns( |
| 129 | 131 | ["2026-08-11T08:37:00.000Z", "2026-08-11T09:37:00.000Z", "2026-08-11T10:37:00.000Z"], |
| 130 | 132 | byHour, |
| 131 | 133 | "cost", |