From 8546fe2333ec9ff40675dd09ba448601a869aa77 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 29 Jan 2025 16:54:49 +0100 Subject: [PATCH] test(server/utils): add tests for isEmptyOrWhitespace --- src/services/utils.spec.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/services/utils.spec.ts b/src/services/utils.spec.ts index 9986f5dc2..6ead22576 100644 --- a/src/services/utils.spec.ts +++ b/src/services/utils.spec.ts @@ -21,7 +21,27 @@ describe.todo("#isElectron", () => {}); describe.todo("#hash", () => {}); -describe.todo("#isEmptyOrWhitespace", () => {}); +describe("#isEmptyOrWhitespace", () => { + + const testCases: TestCase[] = [ + ["w/ 'null' it should return true", [null], true], + ["w/ 'null' it should return true", [null], true], + ["w/ undefined it should return true", [undefined], true], + ["w/ empty string '' it should return true", [""], true], + ["w/ single whitespace string ' ' it should return true", [" "], true], + ["w/ multiple whitespace string ' ' it should return true", [" "], true], + ["w/ non-empty string ' t ' it should return false", [" t "], false], + ]; + + testCases.forEach(testCase => { + const [desc, fnParams, expected] = testCase; + it(desc, () => { + const result = utils.isEmptyOrWhitespace(...fnParams); + expect(result).toStrictEqual(expected); + }) + }) + +}); describe.todo("#sanitizeSqlIdentifier", () => {});