mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
20 lines
571 B
TypeScript
20 lines
571 B
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { createId } from "@/lib/create-id";
|
|
|
|
afterEach(() => vi.unstubAllGlobals());
|
|
|
|
describe("createId", () => {
|
|
it("uses randomUUID when available", () => {
|
|
vi.stubGlobal("crypto", { randomUUID: () => "uuid-1" });
|
|
expect(createId()).toBe("uuid-1");
|
|
});
|
|
|
|
it("falls back without randomUUID, e.g. over plain http", () => {
|
|
vi.stubGlobal("crypto", {});
|
|
const first = createId();
|
|
const second = createId();
|
|
expect(first).toBeTruthy();
|
|
expect(second).not.toBe(first);
|
|
});
|
|
});
|