test.govlab/quality/core/aggregators/catalog.aggregator.test.ts

test.govlab/quality/core/aggregators/catalog.aggregator.test.ts is a file in Codebase Testing. 11 lines of code and 0 definitions.

import { expect, test } from "vitest";
import { tallyBy } from "@govlab/quality/core/aggregators/catalog.aggregator.ts";

test("tallyBy counts rules per value of a field and buckets a missing value as none", () => {
    const rules = [
        { category: "style", ruleId: "a" },
        { category: "style", ruleId: "b" },
        { category: "bugs", ruleId: "c" },
        { ruleId: "d" },
    ];
    expect(tallyBy(rules, "category")).toStrictEqual({ bugs: 1, none: 1, style: 2 });
});