From 1ddade50d9f675ec9105aea42dff248744db642f Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:01:07 +0000 Subject: [PATCH 1/4] Initial empty commit to create PR From 1ee488898405c15cdcea5fc386f95bda09e995c9 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:01:54 +0000 Subject: [PATCH 2/4] Update utils/get-random-item.test.ts [skip ci] --- utils/get-random-item.test.ts | 130 ++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 utils/get-random-item.test.ts diff --git a/utils/get-random-item.test.ts b/utils/get-random-item.test.ts new file mode 100644 index 0000000..183b962 --- /dev/null +++ b/utils/get-random-item.test.ts @@ -0,0 +1,130 @@ +import { getRandomItem } from "./get-random-item"; + +describe("getRandomItem", () => { + describe("single item array", () => { + it("should return the only item in a single-item array", () => { + const items = ["only-item"]; + expect(getRandomItem(items)).toBe("only-item"); + }); + + it("should return the only number in a single-item array", () => { + const items = [42]; + expect(getRandomItem(items)).toBe(42); + }); + + it("should return the only object in a single-item array", () => { + const items = [{ id: 1, name: "test" }]; + expect(getRandomItem(items)).toEqual({ id: 1, name: "test" }); + }); + }); + + describe("multiple items array", () => { + it("should return an item from the array", () => { + const items = ["apple", "banana", "cherry"]; + const result = getRandomItem(items); + expect(items).toContain(result); + }); + + it("should return a number from the array", () => { + const items = [1, 2, 3, 4, 5]; + const result = getRandomItem(items); + expect(items).toContain(result); + }); + + it("should return an object from the array", () => { + const items = [ + { id: 1, name: "first" }, + { id: 2, name: "second" }, + { id: 3, name: "third" }, + ]; + const result = getRandomItem(items); + expect(items).toContainEqual(result); + }); + }); + + describe("different data types", () => { + it("should work with string arrays", () => { + const items = ["a", "b", "c"]; + const result = getRandomItem(items); + expect(typeof result).toBe("string"); + expect(items).toContain(result); + }); + + it("should work with number arrays", () => { + const items = [10, 20, 30]; + const result = getRandomItem(items); + expect(typeof result).toBe("number"); + expect(items).toContain(result); + }); + + it("should work with boolean arrays", () => { + const items = [true, false]; + const result = getRandomItem(items); + expect(typeof result).toBe("boolean"); + expect(items).toContain(result); + }); + + it("should work with mixed type arrays", () => { + const items = [1, "two", true, null, undefined]; + const result = getRandomItem(items); + expect(items).toContain(result); + }); + + it("should work with object arrays", () => { + const items = [ + { type: "user", id: 1 }, + { type: "admin", id: 2 }, + ]; + const result = getRandomItem(items); + expect(items).toContainEqual(result); + }); + + it("should work with nested arrays", () => { + const items = [ + [1, 2], + [3, 4], + [5, 6], + ]; + const result = getRandomItem(items); + expect(items).toContainEqual(result); + }); + }); + + describe("randomness", () => { + it("should be able to return different items over multiple calls", () => { + const items = ["a", "b", "c", "d", "e"]; + const results = new Set(); + + // Call the function many times to collect results + for (let i = 0; i < 100; i++) { + results.add(getRandomItem(items)); + } + + // With 100 calls on 5 items, we should get at least 2 different items + // (probability of getting only 1 item is astronomically low) + expect(results.size).toBeGreaterThan(1); + }); + + it("should potentially return all items given enough calls", () => { + const items = [1, 2, 3]; + const results = new Set(); + + // Call the function many times + for (let i = 0; i < 1000; i++) { + results.add(getRandomItem(items)); + } + + // With 1000 calls on 3 items, we should get all items + // (probability of missing an item is extremely low) + expect(results.size).toBe(3); + }); + }); + + describe("edge cases", () => { + it("should handle empty array", () => { + const items: string[] = []; + const result = getRandomItem(items); + expect(result).toBeUndefined(); + }); + }); +}); From 73712a331e3adfd4904f9d77fcb7e3d7b2125a22 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:02:28 +0000 Subject: [PATCH 3/4] Replace content of utils/get-random-item.test.ts [skip ci] --- utils/get-random-item.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/get-random-item.test.ts b/utils/get-random-item.test.ts index 183b962..d0218d0 100644 --- a/utils/get-random-item.test.ts +++ b/utils/get-random-item.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-var-requires */ import { getRandomItem } from "./get-random-item"; describe("getRandomItem", () => { From 12de45f5a38a4a6ae1e23c72b70194426eeae054 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:02:30 +0000 Subject: [PATCH 4/4] Empty commit to trigger final tests