ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
1import { describe, it, expect } from "vitest";
2import { normalize } from "./string.utils";
3
4describe("String Utils", () => {
5 describe("normalize", () => {
6 it("lowercases the string", () => {
7 expect(normalize("UserName")).toBe("username");
8 expect(normalize("ALLCAPS")).toBe("allcaps");
9 });
10
11 it("removes dots", () => {
12 expect(normalize("user.name")).toBe("username");
13 expect(normalize("a.b.c")).toBe("abc");
14 });
15
16 it("removes underscores", () => {
17 expect(normalize("user_name")).toBe("username");
18 expect(normalize("__leading")).toBe("leading");
19 });
20
21 it("removes hyphens", () => {
22 expect(normalize("user-name")).toBe("username");
23 expect(normalize("--dashes--")).toBe("dashes");
24 });
25
26 it("removes mixed separators", () => {
27 expect(normalize("user.name_with-all")).toBe("usernamewithall");
28 });
29
30 it("lowercases and removes separators together", () => {
31 expect(normalize("User.BSKY.social")).toBe("userbskysocial");
32 expect(normalize("The_Real-Deal.99")).toBe("therealdeal99");
33 });
34
35 it("returns empty string for empty input", () => {
36 expect(normalize("")).toBe("");
37 });
38
39 it("returns string unchanged when no separators present", () => {
40 expect(normalize("already")).toBe("already");
41 });
42
43 it("preserves numbers", () => {
44 expect(normalize("user123")).toBe("user123");
45 expect(normalize("123.456")).toBe("123456");
46 });
47
48 it("preserves other special characters", () => {
49 expect(normalize("user@domain")).toBe("user@domain");
50 expect(normalize("hello world")).toBe("hello world");
51 });
52 });
53});