wundertec-core
Version:
Librería estándar de utilidades e integraciones AWS + helpers generales
10 lines (8 loc) • 332 B
text/typescript
import { groupBy } from "../../src/collections/groupBy";
describe("groupBy()", () => {
it("groups items by provided key function", () => {
const data = [{ id: 1 }, { id: 2 }, { id: 1 }];
const grouped = groupBy(data, (x) => x.id);
expect(grouped).toEqual({ "1": [{ id: 1 }, { id: 1 }], "2": [{ id: 2 }] });
});
});