Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions infrastructure/w3id/tests/utils/uuid.test.ts
Original file line number Diff line number Diff line change
@@ -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",
);
});
});
Loading