From 3d64f8928821b7ad357b3304fe2fbba3dfacb556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20G=C3=BCney=20Y=C4=B1ld=C4=B1r=C4=B1m?= Date: Wed, 2 Sep 2026 23:40:16 +0300 Subject: [PATCH] Refactor Column tests to use parameterized testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replaced repetitive type-checking unit tests in Column.test.ts with Jest's it.each(). - Improved test maintainability, readability, and reduced code duplication (DRY principle). Signed-off-by: Deniz Güney Yıldırım --- src/Scripts/table/Column.test.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Scripts/table/Column.test.ts b/src/Scripts/table/Column.test.ts index 14e958f1..05adfaf4 100644 --- a/src/Scripts/table/Column.test.ts +++ b/src/Scripts/table/Column.test.ts @@ -12,18 +12,12 @@ describe("column", () => { expect(col.class).toBe(columnClass); }); - it("should have id as a string", () => { + it.each([ + ["id"], + ["label"], + ["class"], + ])("should have %s as a string", (property) => { const col = new Column("col2", "Column 2", "class2"); - expect(typeof col.id).toBe("string"); + expect(typeof col[property as keyof Column]).toBe("string"); }); - - it("should have label as a string", () => { - const col = new Column("col3", "Column 3", "class3"); - expect(typeof col.label).toBe("string"); - }); - - it("should have class as a string", () => { - const col = new Column("col4", "Column 4", "class4"); - expect(typeof col.class).toBe("string"); - }); -}); \ No newline at end of file +});