test: 新增测试代码文件

This commit is contained in:
claude-code-best
2026-04-02 14:44:56 +08:00
parent 9c3803d16b
commit 006ad97fbb
32 changed files with 1102 additions and 68 deletions

View File

@@ -38,4 +38,18 @@ describe("objectGroupBy", () => {
expect(result.admin).toHaveLength(2);
expect(result.user).toHaveLength(1);
});
test("handles key function returning undefined", () => {
const result = objectGroupBy([1, 2, 3], () => undefined as any);
expect(result["undefined"]).toEqual([1, 2, 3]);
});
test("handles keys with special characters", () => {
const result = objectGroupBy(
[{ key: "a/b" }, { key: "a.b" }, { key: "a/b" }],
(item) => item.key
);
expect(result["a/b"]).toHaveLength(2);
expect(result["a.b"]).toHaveLength(1);
});
});