From 311891098f6179628ea2dd0e3c1c7c86abc64d9a Mon Sep 17 00:00:00 2001 From: Soham Jaiswal Date: Fri, 25 Apr 2025 09:57:16 +0530 Subject: [PATCH] feat: bad namespace test --- infrastructure/w3id/tests/utils/uuid.test.ts | 34 ++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/infrastructure/w3id/tests/utils/uuid.test.ts b/infrastructure/w3id/tests/utils/uuid.test.ts index e5d36a59..91d723d4 100644 --- a/infrastructure/w3id/tests/utils/uuid.test.ts +++ b/infrastructure/w3id/tests/utils/uuid.test.ts @@ -1,18 +1,26 @@ -import { generateUuid } from "../../src/utils/uuid"; import falso from "@ngneat/falso"; -import { describe, test, expect } from "vitest"; +import { describe, expect, test } from "vitest"; +import { generateUuid } from "../../src/utils/uuid"; describe("UUIDv5 Generation", () => { - test("Create UUID", () => { - const id = generateUuid(falso.randText()); - expect(id).toBeDefined(); - }); + test("Create UUID", () => { + const id = generateUuid(falso.randText()); + expect(id).toBeDefined(); + }); + + test("UUID is deterministic", () => { + const namespace = falso.randUuid(); + const entropy = falso.randText(); + const id = generateUuid(entropy, namespace); + const id2 = generateUuid(entropy, namespace); + expect(id).toEqual(id2); + }); - test("UUID is deterministic", () => { - const namespace = falso.randUuid(); - const entropy = falso.randText(); - const id = generateUuid(entropy, namespace); - const id2 = generateUuid(entropy, namespace); - expect(id).toEqual(id2); - }); + test("UUID Bad Namespace", () => { + const namespace = falso.randText(); + const entropy = falso.randText(); + expect(() => generateUuid(entropy, namespace)).toThrowError( + "Invalid UUID", + ); + }); });