Open History to see the last commit
1import { describe, expect, it } from "@effect/vitest";
2
3import {
4 decodeIssueTrackerCredential,
5 encodeIssueTrackerCredential,
6} from "./IssueTrackerHostLive.ts";
7
8const bytes = (text: string) => new TextEncoder().encode(text);
9
10describe("issue tracker credential storage", () => {
11 it("keeps a key alone as the bare key, the way one was saved before trackers had fields", () => {
12 const credential = { token: "lin_api_123", fields: {} };
13 expect(encodeIssueTrackerCredential(credential)).toEqual(bytes("lin_api_123"));
14 expect(decodeIssueTrackerCredential(bytes("lin_api_123"))).toEqual(credential);
15 });
16
17 it("stores a key with its fields and reads both back", () => {
18 const credential = {
19 token: "tok",
20 fields: { site: "acme.atlassian.net", email: "julius@acme.test" },
21 };
22 expect(decodeIssueTrackerCredential(encodeIssueTrackerCredential(credential))).toEqual(
23 credential,
24 );
25 });
26});