~james/core

core/web/src/lib/components/profile/bio.test.ts -rw-r--r-- 847 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { describe, expect, it } from "vitest";
import { bioSegments } from "#lib/components/profile/bio.ts";

describe("bioSegments", () => {
	it("splits mentions out of surrounding text", () => {
		expect(bioSegments("working on @tangled.org with @Alice.bsky.social.")).toEqual([
			{ kind: "text", text: "working on " },
			{ kind: "mention", handle: "tangled.org" },
			{ kind: "text", text: " with " },
			{ kind: "mention", handle: "alice.bsky.social" },
			{ kind: "text", text: "." }
		]);
	});

	it("leaves emails and dotless names as text", () => {
		expect(bioSegments("mail me@example.com or @nobody")).toEqual([
			{ kind: "text", text: "mail me@example.com or @nobody" }
		]);
	});

	it("keeps a mention at the very start", () => {
		expect(bioSegments("@bob.tngl.sh")).toEqual([{ kind: "mention", handle: "bob.tngl.sh" }]);
	});
});