import { describe, expect, it } from "vite-plus/test"; import { resolveThreadReferenceCopyTarget } from "./threadReference.ts"; describe("resolveThreadReferenceCopyTarget", () => { it("does not copy another reference while the open panel URL is unavailable", () => { expect( resolveThreadReferenceCopyTarget({ threadId: "thread-1", openPanelPullRequestUrl: null, linkedPullRequestUrl: "https://github.com/t3/pr/12", }), ).toBeNull(); }); it("prefers the open panel pull request over the thread pull request", () => { expect( resolveThreadReferenceCopyTarget({ threadId: "thread-1", openPanelPullRequestUrl: "https://github.com/t3/pr/14", linkedPullRequestUrl: "https://github.com/t3/pr/12", }), ).toMatchObject({ kind: "pull-request", value: "https://github.com/t3/pr/14", successTitle: "PR link copied", }); }); it("uses the thread pull request when no panel is open", () => { expect( resolveThreadReferenceCopyTarget({ threadId: "thread-1", linkedPullRequestUrl: "https://github.com/t3/pr/12", }), ).toMatchObject({ kind: "pull-request", value: "https://github.com/t3/pr/12", successTitle: "PR link copied", }); }); it("falls back to the thread ID", () => { expect(resolveThreadReferenceCopyTarget({ threadId: "thread-1" })).toEqual({ kind: "thread", value: "thread-1", clipboardTarget: "thread ID", successTitle: "Thread ID copied", failureTitle: "Failed to copy thread ID", }); }); });