From 05a0acbdb518483dc7b37772ebd84ffae2b7dc15 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 29 Jan 2025 19:05:13 +0100 Subject: [PATCH] test(server/utils): add tests for newEntityId and randomString --- src/services/utils.spec.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/services/utils.spec.ts b/src/services/utils.spec.ts index 57f658b5b..36eae4e82 100644 --- a/src/services/utils.spec.ts +++ b/src/services/utils.spec.ts @@ -1,9 +1,28 @@ import { describe, it, expect } from "vitest"; import utils from "./utils.js"; -describe.todo("#newEntityId", () => {}); +type TestCase any> = [desc: string, fnParams: Parameters, expected: ReturnType]; -describe.todo("#randomString", () => {}); +describe("#newEntityId", () => { + + it("should return a string with a length of 12", () => { + const result = utils.newEntityId(); + expect(result).toBeTypeOf("string"); + expect(result).toHaveLength(12); + }); + +}); + +describe("#randomString", () => { + + it("should return a string with a length as per argument", () => { + const stringLength = 5; + const result = utils.randomString(stringLength); + expect(result).toBeTypeOf("string"); + expect(result).toHaveLength(stringLength); + }); + +}); describe.todo("#randomSecureToken", () => {});