mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-18 13:57:52 -04:00
22 lines
732 B
TypeScript
22 lines
732 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { isValidUsername, normalizeUsername } from "~/lib/username";
|
|
|
|
describe("username helpers", () => {
|
|
test("normalizes usernames by trimming and lowercasing", () => {
|
|
expect(normalizeUsername(" Admin-User ")).toBe("admin-user");
|
|
});
|
|
|
|
test("accepts usernames containing a hyphen", () => {
|
|
expect(isValidUsername(normalizeUsername("Admin-User"))).toBe(true);
|
|
});
|
|
|
|
test("accepts letters, numbers, dots, and underscores", () => {
|
|
expect(isValidUsername("admin.user_01")).toBe(true);
|
|
});
|
|
|
|
test("rejects usernames with unsupported characters", () => {
|
|
expect(isValidUsername("admin user")).toBe(false);
|
|
expect(isValidUsername("admin@user")).toBe(false);
|
|
});
|
|
});
|