|
1 |
| -import { generateUuid } from "../../src/utils/uuid"; |
2 | 1 | import falso from "@ngneat/falso";
|
3 |
| -import { describe, test, expect } from "vitest"; |
| 2 | +import { describe, expect, test } from "vitest"; |
| 3 | +import { generateUuid } from "../../src/utils/uuid"; |
4 | 4 |
|
5 | 5 | describe("UUIDv5 Generation", () => {
|
6 |
| - test("Create UUID", () => { |
7 |
| - const id = generateUuid(falso.randText()); |
8 |
| - expect(id).toBeDefined(); |
9 |
| - }); |
| 6 | + test("Create UUID", () => { |
| 7 | + const id = generateUuid(falso.randText()); |
| 8 | + expect(id).toBeDefined(); |
| 9 | + }); |
| 10 | + |
| 11 | + test("UUID is deterministic", () => { |
| 12 | + const namespace = falso.randUuid(); |
| 13 | + const entropy = falso.randText(); |
| 14 | + const id = generateUuid(entropy, namespace); |
| 15 | + const id2 = generateUuid(entropy, namespace); |
| 16 | + expect(id).toEqual(id2); |
| 17 | + }); |
10 | 18 |
|
11 |
| - test("UUID is deterministic", () => { |
12 |
| - const namespace = falso.randUuid(); |
13 |
| - const entropy = falso.randText(); |
14 |
| - const id = generateUuid(entropy, namespace); |
15 |
| - const id2 = generateUuid(entropy, namespace); |
16 |
| - expect(id).toEqual(id2); |
17 |
| - }); |
| 19 | + test("UUID Bad Namespace", () => { |
| 20 | + const namespace = falso.randText(); |
| 21 | + const entropy = falso.randText(); |
| 22 | + expect(() => generateUuid(entropy, namespace)).toThrowError( |
| 23 | + "Invalid UUID", |
| 24 | + ); |
| 25 | + }); |
18 | 26 | });
|
0 commit comments