diff --git a/test/unit/connect.test.ts b/test/unit/connect.test.ts index 2624456..631a36f 100644 --- a/test/unit/connect.test.ts +++ b/test/unit/connect.test.ts @@ -104,10 +104,10 @@ describe("prepareConnection", () => { }) it("shows a refusal with its action, then closes the remote", async () => { - const { deps, seen } = setup({ FAKE_SPIN_ERROR: "no_key_held" }) + const { deps, seen } = setup({ FAKE_SPIN_ERROR: "key_not_enrolled" }) expect(await prepareConnection(deps, "ssh-remote", "ssh-remote+spin.my-ws")).toBe(false) expect(seen.errors).toHaveLength(1) - expect((seen.errors[0] as CliError).code).toBe("no_key_held") + expect((seen.errors[0] as CliError).code).toBe("key_not_enrolled") expect(seen.closed).toBe(1) }) diff --git a/test/unit/proxy.test.ts b/test/unit/proxy.test.ts index e9380bd..4b4fa21 100644 --- a/test/unit/proxy.test.ts +++ b/test/unit/proxy.test.ts @@ -117,15 +117,19 @@ describe("fileProxyStatus", () => { }) describe("proxyFailure", () => { - it("is the CLI's envelope for a code the contract knows", () => { - const error = { code: "no_capacity", action: "retry", message: "full" } - expect(proxyFailure(status("failed", { error }))).toEqual({ envelope: { error } }) + it.each([ + ["a refusal", "refused", KEY_NOT_ENROLLED], + ["a failure", "failed", { code: "no_capacity", action: "retry", message: "full" }], + ] as const)("is the CLI's envelope, with its action, for %s", (_what, phase, error) => { + expect(proxyFailure(status(phase, { error }))).toEqual({ envelope: { error } }) }) + // A release newer than the contract can write a code it does not know yet. it("is the message and its page for a code the contract does not know", () => { - expect(proxyFailure(status("refused", { error: KEY_NOT_ENROLLED }))).toEqual({ - message: `Spinbox could not connect to ${HOST}: ${KEY_NOT_ENROLLED.message}`, - url: KEY_NOT_ENROLLED.url, + const error = { ...KEY_NOT_ENROLLED, code: "key_revoked" } + expect(proxyFailure(status("refused", { error }))).toEqual({ + message: `Spinbox could not connect to ${HOST}: ${error.message}`, + url: error.url, }) })