From 3aa2120bc5bfe3546566d090ed15d2a7e4879196 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 04:39:08 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Add=20?= =?UTF-8?q?unit=20tests=20for=20cn=20utility=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎯 What: Added unit tests for the previously untested `cn` function in `src/utils/helper.ts`. 📊 Coverage: Tested multiple valid strings, ignoring undefined/falsy values, ignoring empty strings, and handling an empty input list. ✨ Result: `cn` is now thoroughly tested and regressions in it can be easily caught. Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- src/utils/helper.test.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/utils/helper.test.ts b/src/utils/helper.test.ts index 24a366a..e21e9b7 100644 --- a/src/utils/helper.test.ts +++ b/src/utils/helper.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'bun:test'; -import { isExpVersion, isPasswordValid } from './helper'; +import { cn, isExpVersion, isPasswordValid } from './helper'; describe('isPasswordValid', () => { test('should return true for valid passwords', () => { @@ -65,3 +65,25 @@ describe('isExpVersion', () => { expect(isExpVersion({ rollout: { '1.0.0': 110 } }, '1.0.0')).toBe(false); }); }); + +describe('cn', () => { + test('should combine multiple valid strings', () => { + expect(cn('class1', 'class2', 'class3')).toBe('class1 class2 class3'); + }); + + test('should ignore undefined values', () => { + expect(cn('class1', undefined, 'class2')).toBe('class1 class2'); + }); + + test('should ignore empty strings', () => { + expect(cn('class1', '', 'class2')).toBe('class1 class2'); + }); + + test('should return empty string when handling an empty input list', () => { + expect(cn()).toBe(''); + }); + + test('should return empty string when all inputs are falsy', () => { + expect(cn('', undefined)).toBe(''); + }); +});