aboutsummaryrefslogtreecommitdiff
path: root/src/scraper.test.ts
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-07-15 00:16:30 -0400
committerJoe Mou <dev@mou.fo>2026-07-15 00:43:28 -0400
commitb3e6a7029756b5cd83e39cd282668b740177a428 (patch)
tree07ecf4eaff1d566f2fa29763492742ccfc50746f /src/scraper.test.ts
parentbd084291d30f57b8432b2e9fd522938be8ed10e3 (diff)
User profile pages
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'src/scraper.test.ts')
-rw-r--r--src/scraper.test.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/scraper.test.ts b/src/scraper.test.ts
index a4b834e..4a01853 100644
--- a/src/scraper.test.ts
+++ b/src/scraper.test.ts
@@ -9,6 +9,7 @@ import {
getGitHubReleases,
getGitHubRepo,
getGitHubTree,
+ getGitHubUser,
GitHubHTTPError,
RedirectError,
} from "./scraper.ts";
@@ -264,6 +265,54 @@ describe("GitHub scraper", () => {
});
});
+ describe("user pages", () => {
+ it("should fetch user profile", async () => {
+ const data = await getGitHubUser("torvalds");
+
+ assert.strictEqual(data.login, "torvalds");
+ assert.strictEqual(data.name, "Linus Torvalds");
+ assert.strictEqual(data.company, "Linux Foundation");
+ assert.strictEqual(data.location, "Portland, OR");
+ assert.ok(data.avatarUrl?.startsWith("https://avatars.githubusercontent.com/"));
+ assert.ok(data.followers);
+ assert.ok(data.following !== null);
+
+ assert.ok(data.pinned.length > 0);
+ const linux = data.pinned.find((repo) => repo.name === "linux");
+ assert.ok(linux);
+ assert.strictEqual(linux.owner, "torvalds");
+ assert.strictEqual(linux.description, "Linux kernel source tree");
+ assert.strictEqual(linux.language, "C");
+ assert.ok(linux.stars);
+ assert.ok(linux.forks);
+ });
+
+ it("should fetch user bio and links", async () => {
+ const data = await getGitHubUser("sindresorhus");
+
+ assert.strictEqual(data.login, "sindresorhus");
+ assert.ok(data.bio && data.bio.length > 0);
+ assert.ok(data.links.length > 0);
+ assert.ok(data.links.every((link) => link.href.startsWith("https://")));
+ });
+
+ it("should redirect to GitHub for organizations", async () => {
+ await assert.rejects(getGitHubUser("github"), (err) => {
+ assert(err instanceof RedirectError, "error should be a RedirectError");
+ assert.strictEqual(err.location, "https://github.com/github");
+ return true;
+ });
+ });
+
+ it("should throw for non-existent user", async () => {
+ await assert.rejects(getGitHubUser("nosuchuserzzzz"), (err) => {
+ assert(err instanceof GitHubHTTPError, "error should be an HTTPError");
+ assert.strictEqual(err.status, 404);
+ return true;
+ });
+ });
+ });
+
describe("error handling", () => {
it("should throw for non-existent repository", async () => {
await assert.rejects(getGitHubRepo("nosuchowner", "nosuchrepo"), (err) => {