Skip to content

Commit f60fed9

Browse files
committed
test(url-helpers): add href and label utility coverage
1 parent f049236 commit f60fed9

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import assert from "node:assert";
2+
import { describe, it } from "node:test";
3+
import {
4+
ensureHref,
5+
githubLabel,
6+
linkedinLabel,
7+
websiteLabel,
8+
} from "../url-helpers";
9+
10+
describe("url-helpers", () => {
11+
it("keeps http/https URLs unchanged", () => {
12+
assert.strictEqual(ensureHref("https://example.com"), "https://example.com");
13+
assert.strictEqual(ensureHref("http://example.com"), "http://example.com");
14+
});
15+
16+
it("prefixes protocol for plain hostnames", () => {
17+
assert.strictEqual(ensureHref("example.com"), "https://example.com");
18+
});
19+
20+
it("maps email-like input to mailto", () => {
21+
assert.strictEqual(ensureHref("user@example.com"), "mailto:user@example.com");
22+
});
23+
24+
it("returns empty string for empty input", () => {
25+
assert.strictEqual(ensureHref(""), "");
26+
});
27+
28+
it("returns stable display labels", () => {
29+
assert.strictEqual(websiteLabel(), "Portfolio");
30+
assert.strictEqual(linkedinLabel(), "LinkedIn");
31+
assert.strictEqual(githubLabel(), "GitHub");
32+
});
33+
});

0 commit comments

Comments
 (0)