feat(ui): helper sumUpdates (TDD)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { sumUpdates } from "./stats.js";
|
||||||
|
|
||||||
|
describe("sumUpdates", () => {
|
||||||
|
it("somme les compteurs", () => {
|
||||||
|
expect(sumUpdates({ a: 2, b: 3, c: 0 })).toBe(5);
|
||||||
|
});
|
||||||
|
it("retourne 0 pour un objet vide", () => {
|
||||||
|
expect(sumUpdates({})).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// client/src/lib/stats.ts
|
||||||
|
export function sumUpdates(counts: Record<string, number>): number {
|
||||||
|
return Object.values(counts).reduce((acc, n) => acc + n, 0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user