This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / web / src / lib / api / repoIndex.test.ts
1.1 kB 34 lines
1import { describe, expect, it } from "vitest"; 2import { ClientResponseError } from "./client"; 3import { classifyRepoAvailability } from "./repoIndex"; 4 5const unsupported = () => 6 new ClientResponseError({ status: 404, data: { error: "XRPCNotSupported" } }); 7 8describe("classifyRepoAvailability", () => { 9 it("recognizes a legacy knot that does not expose repository endpoints", () => { 10 const result = classifyRepoAvailability( 11 [unsupported(), unsupported(), unsupported()].map((cause) => ({ value: null, error: cause })) 12 ); 13 14 expect(result).toBe("needs-upgrade"); 15 }); 16 17 it("keeps transport failures as unreachable", () => { 18 const result = classifyRepoAvailability( 19 ["tree", "log", "branches"].map(() => ({ value: null, error: new TypeError("offline") })) 20 ); 21 22 expect(result).toBe("unreachable"); 23 }); 24 25 it("does not mistake a missing ref for an unavailable knot", () => { 26 const result = classifyRepoAvailability([ 27 { value: null, error: unsupported() }, 28 { value: null, error: unsupported() }, 29 { value: { branches: [] }, error: null } 30 ]); 31 32 expect(result).toBe("ok"); 33 }); 34});