NanoID_test.res.mjs
1// Generated by ReScript, PLEASE EDIT WITH CARE
2
3import * as NanoID from "../src/ffi/NanoID.res.mjs";
4import * as Nanoid from "nanoid";
5import * as Vitest from "vitest";
6
7Vitest.describe("NanoID", () => {
8 Vitest.test("make returns string of default length 10", async t => {
9 let id = NanoID.make();
10 t.expect(id.length).toEqual(10);
11 });
12 Vitest.test("make returns unique IDs on multiple calls", async t => {
13 let id1 = NanoID.make();
14 let id2 = NanoID.make();
15 t.expect(id1 === id2).toEqual(false);
16 });
17 Vitest.test("make returns URL-safe characters only", async t => {
18 let id = NanoID.make();
19 let isUrlSafe = /^[A-Za-z0-9_-]+$/.test(id);
20 t.expect(isUrlSafe).toEqual(true);
21 });
22 Vitest.test("makeLen returns string of specified length 5", async t => {
23 let id = Nanoid.nanoid(5);
24 t.expect(id.length).toEqual(5);
25 });
26 Vitest.test("makeLen returns string of specified length 21", async t => {
27 let id = Nanoid.nanoid(21);
28 t.expect(id.length).toEqual(21);
29 });
30 Vitest.test("makeLen returns string of specified length 1", async t => {
31 let id = Nanoid.nanoid(1);
32 t.expect(id.length).toEqual(1);
33 });
34 Vitest.test("makeLen returns unique IDs on multiple calls", async t => {
35 let id1 = Nanoid.nanoid(10);
36 let id2 = Nanoid.nanoid(10);
37 t.expect(id1 === id2).toEqual(false);
38 });
39 Vitest.test("makeLen returns URL-safe characters only", async t => {
40 let id = Nanoid.nanoid(15);
41 let isUrlSafe = /^[A-Za-z0-9_-]+$/.test(id);
42 t.expect(isUrlSafe).toEqual(true);
43 });
44});
45
46/* Not a pure module */