Open History to see the last commit
1import { ThreadId } from "@t3tools/contracts";
2import { renderToStaticMarkup } from "react-dom/server";
3import { describe, expect, it } from "vite-plus/test";
4
5import { ThreadWorktreeIndicator } from "./ThreadStatusIndicators";
6
7describe("ThreadWorktreeIndicator", () => {
8 it("renders the worktree folder and branch in an accessible label", () => {
9 const markup = renderToStaticMarkup(
10 <ThreadWorktreeIndicator
11 thread={{
12 id: ThreadId.make("thread-1"),
13 branch: "feature/sidebar-indicator",
14 worktreePath: "/tmp/worktrees/sidebar-indicator",
15 }}
16 />,
17 );
18
19 expect(markup).toContain('role="img"');
20 expect(markup).toContain(
21 'aria-label="Worktree: sidebar-indicator (feature/sidebar-indicator)"',
22 );
23 expect(markup).toContain('data-testid="thread-worktree-thread-1"');
24 });
25
26 it.each([null, "", " "])("renders nothing for an absent worktree path", (worktreePath) => {
27 const markup = renderToStaticMarkup(
28 <ThreadWorktreeIndicator
29 thread={{
30 id: ThreadId.make("thread-1"),
31 branch: "main",
32 worktreePath,
33 }}
34 />,
35 );
36
37 expect(markup).toBe("");
38 });
39});