From: Jérôme Benoit Date: Wed, 25 Jan 2023 23:17:18 +0000 (+0100) Subject: Revert incorrect isEmptyString() semantic change X-Git-Tag: v1.1.92~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4e276cc7fe5ba6090afa4cb7b45b0f0885d0f149;p=e-mobility-charging-stations-simulator.git Revert incorrect isEmptyString() semantic change Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 0952be9b..6557a588 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -193,7 +193,7 @@ export default class Utils { } public static isEmptyString(value: unknown): boolean { - return Utils.isString(value) ? (value as string).trim().length === 0 : true; + return Utils.isString(value) && (value as string).trim().length === 0; } public static isUndefined(value: unknown): boolean { diff --git a/test/utils/UtilsTest.ts b/test/utils/UtilsTest.ts index a3166aed..21d5d137 100644 --- a/test/utils/UtilsTest.ts +++ b/test/utils/UtilsTest.ts @@ -161,15 +161,15 @@ describe('Utils test suite', () => { expect(Utils.isEmptyString('test')).toBe(false); expect(Utils.isEmptyString(' test')).toBe(false); expect(Utils.isEmptyString('test ')).toBe(false); - expect(Utils.isEmptyString(null)).toBe(true); - expect(Utils.isEmptyString(undefined)).toBe(true); - expect(Utils.isEmptyString(0)).toBe(true); - expect(Utils.isEmptyString({})).toBe(true); - expect(Utils.isEmptyString([])).toBe(true); - expect(Utils.isEmptyString(new Map())).toBe(true); - expect(Utils.isEmptyString(new Set())).toBe(true); - expect(Utils.isEmptyString(new WeakMap())).toBe(true); - expect(Utils.isEmptyString(new WeakSet())).toBe(true); + expect(Utils.isEmptyString(null)).toBe(false); + expect(Utils.isEmptyString(undefined)).toBe(false); + expect(Utils.isEmptyString(0)).toBe(false); + expect(Utils.isEmptyString({})).toBe(false); + expect(Utils.isEmptyString([])).toBe(false); + expect(Utils.isEmptyString(new Map())).toBe(false); + expect(Utils.isEmptyString(new Set())).toBe(false); + expect(Utils.isEmptyString(new WeakMap())).toBe(false); + expect(Utils.isEmptyString(new WeakSet())).toBe(false); }); it('Verify isUndefined()', () => {