32 lines · 1.2 KB · TypeScript
RawDownload
import { isValidElement, type ReactElement, type ReactNode } from "react";import { describe, expect, it } from "vite-plus/test"; import { PullRequestsUnavailableState } from "./PullRequestsUnavailableState"; function textOf(node: ReactNode): string {  if (typeof node === "string" || typeof node === "number") return String(node);  if (Array.isArray(node)) return node.map(textOf).join(" ");  if (!isValidElement(node)) return "";  return textOf((node as ReactElement<{ children?: ReactNode }>).props.children);} describe("PullRequestsUnavailableState", () => {  it("can explain an unsupported environment without offering a futile retry", () => {    const text = textOf(      PullRequestsUnavailableState({        title: "Pull requests unavailable",        error: "Update this environment's T3 Code server to browse pull requests.",      }),    );     expect(text).toContain("Pull requests unavailable");    expect(text).toContain("Update this environment's T3 Code server");    expect(text).not.toContain("Retry");  });   it("retains the retry for transient load failures", () => {    expect(      textOf(PullRequestsUnavailableState({ error: "GitHub did not answer.", onRetry: () => {} })),    ).toContain("Retry");  });});

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