UNPKG

numeric-uuid

Version:

A simple library to generate unique numeric UUIDs

19 lines (15 loc) 553 B
const NumericUUID = require("../index"); test("Generates a unique numeric UUID of correct length", () => { const id = NumericUUID.generate(20); expect(id.length).toBe(20); expect(!isNaN(id)).toBe(true); }); test("Throws error for invalid length", () => { expect(() => NumericUUID.generate(9)).toThrow(); expect(() => NumericUUID.generate(31)).toThrow(); }); test("Generates different UUIDs on each call", () => { const id1 = NumericUUID.generate(); const id2 = NumericUUID.generate(); expect(id1).not.toBe(id2); });