import { describe, expect, it } from "vitest";
import { normalizeHandle } from "#lib/handle.ts";
describe("normalizeHandle", () => {
it("strips the bidi marks a handle copied from bsky.app carries", () => {
expect(normalizeHandle("\u202a@nelind.dk\u202c")).toBe("nelind.dk");
});
it("strips a right-to-left override anywhere in the handle", () => {
expect(normalizeHandle("evil\u202egro.delgnat")).toBe("evilgro.delgnat");
});
it("trims, drops a leading @ and lowercases", () => {
expect(normalizeHandle(" @Alice.Tngl.SH ")).toBe("alice.tngl.sh");
});
it("keeps a did's case", () => {
expect(normalizeHandle("\u202adid:web:Example.com\u202c")).toBe("did:web:Example.com");
});
});