Files
zerobyte/app/server/lib/__tests__/username.test.ts
Nico 4305057185 test: move test runner from Bun to Vitest (#727)
* chore: migrate to vitest

* test: speed up some suites by sharing sessions and mocking expensive non-tested actions

* test: refactor some tests to verify behavior instead of implementation details

* chore: fix linting issues
2026-04-01 20:05:54 +02:00

22 lines
730 B
TypeScript

import { describe, expect, test } from "vitest";
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);
});
});