import { describe, expect, it } from "vitest"; import { downloadPlanFor } from "./download.js"; describe("downloadPlanFor", () => { it("plans an npm install for the official TypeScript server", () => { const plan = downloadPlanFor({ id: "typescript", download: "npm" }); expect(plan).toEqual({ kind: "npm", package: "typescript-language-server", bin: "typescript-language-server", }); }); it("plans a GitHub release download for kotlin-lsp", () => { const plan = downloadPlanFor({ id: "kotlin", download: "github-release" }); expect(plan?.kind).toBe("github-release"); if (plan?.kind === "github-release") { expect(plan.owner).toBe("Kotlin"); expect(plan.repo).toBe("kotlin-lsp"); expect(plan.bin).toBe("kotlin-lsp"); } }); it("plans a go install for gopls", () => { const plan = downloadPlanFor({ id: "gopls", download: "go-install" }); expect(plan).toEqual({ kind: "go-install", package: "golang.org/x/tools/gopls@latest", bin: "gopls", }); }); it("returns undefined for servers without auto-download", () => { expect(downloadPlanFor({ id: "clangd" })).toBeUndefined(); }); it("returns undefined for unknown download kinds", () => { expect(downloadPlanFor({ id: "weird", download: "unknown" as never })).toBeUndefined(); }); });