Skip to content

Commit 1640869

Browse files
committed
feat: add tests for generateUuid
1 parent 940f14d commit 1640869

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/util.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { JSDOM } from "jsdom"
44
import { logger } from "../node_modules/@coder/logger"
55
import {
66
arrayify,
7+
generateUuid,
78
getFirstString,
89
getOptions,
910
logError,
@@ -55,6 +56,20 @@ describe("util", () => {
5556
})
5657
})
5758

59+
describe("generateUuid", () => {
60+
it("should generate a unique uuid", () => {
61+
const uuid = generateUuid()
62+
const uuid2 = generateUuid()
63+
expect(uuid).toHaveLength(24)
64+
expect(typeof uuid).toBe("string")
65+
expect(uuid).not.toBe(uuid2)
66+
})
67+
it("should generate a uuid of a specific length", () => {
68+
const uuid = generateUuid(10)
69+
expect(uuid).toHaveLength(10)
70+
})
71+
})
72+
5873
describe("trimSlashes", () => {
5974
it("should remove leading slashes", () => {
6075
expect(trimSlashes("/hello-world")).toBe("hello-world")

0 commit comments

Comments
 (0)