The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { SecretProviderId } from "@t3tools/contracts"; |
| 2 | import * as Result from "effect/Result"; |
| 3 | import { describe, expect, it } from "vite-plus/test"; |
| 4 | |
| 5 | import { secretProviderFromDraft } from "./SecretProviderDialog.logic"; |
| 6 | |
| 7 | describe("secretProviderFromDraft", () => { |
| 8 | it("adds a provider keyed by its name and reports every field that blocks it", () => { |
| 9 | expect( |
| 10 | secretProviderFromDraft({ name: " 1Password! ", account: "my.1password.com" }, new Set(), { |
| 11 | mode: "add", |
| 12 | }), |
| 13 | ).toEqual( |
| 14 | Result.succeed({ |
| 15 | id: "1password", |
| 16 | config: { |
| 17 | kind: "one_password", |
| 18 | label: "1Password!", |
| 19 | config: { account: "my.1password.com" }, |
| 20 | }, |
| 21 | }), |
| 22 | ); |
| 23 | |
| 24 | const blocked = secretProviderFromDraft( |
| 25 | { name: "1Password", account: "--help" }, |
| 26 | new Set(["1password"]), |
| 27 | { mode: "add" }, |
| 28 | ); |
| 29 | expect(Result.isFailure(blocked) && Object.keys(blocked.failure).toSorted()).toEqual([ |
| 30 | "account", |
| 31 | "name", |
| 32 | ]); |
| 33 | }); |
| 34 | |
| 35 | it("keeps the id when an edit renames the provider", () => { |
| 36 | const id = SecretProviderId.make("personal"); |
| 37 | const result = secretProviderFromDraft( |
| 38 | { name: "Personal (team)", account: "team.1password.com" }, |
| 39 | new Set(["personal"]), |
| 40 | { mode: "edit", id }, |
| 41 | ); |
| 42 | expect(Result.isSuccess(result) && result.success).toEqual({ |
| 43 | id, |
| 44 | config: { |
| 45 | kind: "one_password", |
| 46 | label: "Personal (team)", |
| 47 | config: { account: "team.1password.com" }, |
| 48 | }, |
| 49 | }); |
| 50 | }); |
| 51 | }); |