Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.2 kB · 42 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243import { describe, expect, it } from "vitest";import { formatHandle, formatHandleWithAt } from "./format-handle";
describe("formatHandle", () => { it("returns handle when valid", () => { expect( formatHandle({ handle: "alice.bsky.social", did: "did:plc:abc" }), ).toBe("alice.bsky.social"); });
it("returns did when handle is invalid", () => { expect(formatHandle({ handle: "handle.invalid", did: "did:plc:abc" })).toBe( "did:plc:abc", ); });
it("prepends prefix when given", () => { expect( formatHandle({ handle: "alice.bsky.social", did: "did:plc:abc" }, "@"), ).toBe("@alice.bsky.social"); });
it("does not prepend prefix when handle is invalid", () => { expect( formatHandle({ handle: "handle.invalid", did: "did:plc:abc" }, "@"), ).toBe("did:plc:abc"); });});
describe("formatHandleWithAt", () => { it("returns @handle for valid handle", () => { expect( formatHandleWithAt({ handle: "bob.bsky.social", did: "did:plc:def" }), ).toBe("@bob.bsky.social"); });
it("returns did for invalid handle", () => { expect( formatHandleWithAt({ handle: "handle.invalid", did: "did:plc:def" }), ).toBe("did:plc:def"); });});