From 7c9443f55b4130b390f8f824a5f8a71269710998 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 28 Mar 2026 01:02:08 +0100 Subject: [PATCH] test: add whitespace-padded value coverage for convertToBoolean Align test coverage across root simulator and web UI components for trim handling of ' true ', ' 1 ', ' false ', ' TRUE ', 'True', 'FALSE', and numeric 2. --- tests/utils/Utils.test.ts | 6 ++++++ ui/web/tests/unit/Utils.test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 767b86fd..cf87126f 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -214,6 +214,7 @@ await describe('Utils', async () => { assert.strictEqual(convertToBoolean('false'), false) assert.strictEqual(convertToBoolean('TRUE'), true) assert.strictEqual(convertToBoolean('FALSE'), false) + assert.strictEqual(convertToBoolean('True'), true) assert.strictEqual(convertToBoolean('1'), true) assert.strictEqual(convertToBoolean('0'), false) assert.strictEqual(convertToBoolean(1), true) @@ -222,6 +223,11 @@ await describe('Utils', async () => { assert.strictEqual(convertToBoolean(false), false) assert.strictEqual(convertToBoolean(''), false) assert.strictEqual(convertToBoolean('NoNBoolean'), false) + assert.strictEqual(convertToBoolean(2), false) + assert.strictEqual(convertToBoolean(' true '), true) + assert.strictEqual(convertToBoolean(' 1 '), true) + assert.strictEqual(convertToBoolean(' false '), false) + assert.strictEqual(convertToBoolean(' TRUE '), true) }) await it('should generate cryptographically secure random numbers between 0 and 1', () => { diff --git a/ui/web/tests/unit/Utils.test.ts b/ui/web/tests/unit/Utils.test.ts index 4714ed17..d5fefcb7 100644 --- a/ui/web/tests/unit/Utils.test.ts +++ b/ui/web/tests/unit/Utils.test.ts @@ -38,6 +38,14 @@ describe('Utils', () => { expect(convertToBoolean('True')).toBe(true) }) + it('should return true for string "TRUE" (case-insensitive)', () => { + expect(convertToBoolean('TRUE')).toBe(true) + }) + + it('should return false for string "FALSE" (case-insensitive)', () => { + expect(convertToBoolean('FALSE')).toBe(false) + }) + it('should return true for string "1"', () => { expect(convertToBoolean('1')).toBe(true) }) @@ -77,6 +85,22 @@ describe('Utils', () => { it('should return false for numeric 2', () => { expect(convertToBoolean(2)).toBe(false) }) + + it('should return true for whitespace-padded "true"', () => { + expect(convertToBoolean(' true ')).toBe(true) + }) + + it('should return true for whitespace-padded "1"', () => { + expect(convertToBoolean(' 1 ')).toBe(true) + }) + + it('should return false for whitespace-padded "false"', () => { + expect(convertToBoolean(' false ')).toBe(false) + }) + + it('should return true for whitespace-padded "TRUE"', () => { + expect(convertToBoolean(' TRUE ')).toBe(true) + }) }) describe('convertToInt', () => { -- 2.53.0