30 lines · 1.1 KB · TypeScript
RawDownload
import { describe, expect, it, vi } from "vite-plus/test"; import { openPullRequestLink, PullRequestLinkOpenError } from "./openPullRequestLink"; describe("openPullRequestLink", () => {  it("opens the requested pull request URL", async () => {    const openExternal = vi.fn(async () => undefined);    const targetUrl = "https://github.com/pingdotgg/t3code/pull/123";     await openPullRequestLink({ openExternal }, targetUrl);     expect(openExternal).toHaveBeenCalledExactlyOnceWith(targetUrl);  });   it("reports bridge failures with a safe target origin", async () => {    const cause = new Error("desktop shell unavailable");    const targetUrl = "https://github.com/pingdotgg/t3code/pull/123?token=secret";    const openExternal = vi.fn(async () => Promise.reject(cause));     const result = openPullRequestLink({ openExternal }, targetUrl);     await expect(result).rejects.toEqual(      new PullRequestLinkOpenError({        targetOrigin: "https://github.com",        cause,      }),    );    await expect(result).rejects.not.toHaveProperty("message", expect.stringContaining("secret"));  });});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t