Skip to content

Commit 2267645

Browse files
authored
feat: bad namespace test (#116)
1 parent bd4f5b2 commit 2267645

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed
Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
import { generateUuid } from "../../src/utils/uuid";
21
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";
44

55
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+
});
1018

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+
});
1826
});

0 commit comments

Comments
 (0)