Skip to content

Commit 22f885b

Browse files
alexandre-mrtclaude
andcommitted
test: add nanoid URL-safe format tests (133 tests)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a231a42 commit 22f885b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/nanoid-format.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, expect, test } from "bun:test";
2+
import { nanoid } from "nanoid";
3+
4+
describe("nanoid format for drop IDs", () => {
5+
test("custom length produces exact size", () => {
6+
expect(nanoid(10).length).toBe(10);
7+
expect(nanoid(21).length).toBe(21);
8+
});
9+
10+
test("only contains URL-safe chars", () => {
11+
for (let i = 0; i < 50; i++) {
12+
const id = nanoid(10);
13+
expect(id).toMatch(/^[A-Za-z0-9_-]+$/);
14+
}
15+
});
16+
});

0 commit comments

Comments
 (0)