mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
16 lines
524 B
TypeScript
16 lines
524 B
TypeScript
// @vitest-environment jsdom
|
|
import { describe, expect, it } from "vitest";
|
|
import { generateId } from "../../../apps/web/src/lib/utils";
|
|
|
|
describe("generateId", () => {
|
|
it("returns a valid UUID v4 string", () => {
|
|
const id = generateId();
|
|
expect(id).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
|
|
});
|
|
|
|
it("returns unique values on successive calls", () => {
|
|
const ids = new Set(Array.from({ length: 100 }, () => generateId()));
|
|
expect(ids.size).toBe(100);
|
|
});
|
|
});
|