Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AgentActivity.test.ts

49 lines1.4 KB

1import { describe, expect, it, vi } from "vite-plus/test";
2​
3vi.mock("@expo/ui/swift-ui", () => ({
4 HStack: "HStack",
5 Spacer: "Spacer",
6 Text: "Text",
7 VStack: "VStack",
8}));
9​
10vi.mock("@expo/ui/swift-ui/modifiers", () => ({
11 font: (value: unknown) => value,
12 foregroundStyle: (value: unknown) => value,
13 lineLimit: (value: unknown) => value,
14 padding: (value: unknown) => value,
15}));
16​
17vi.mock("expo-widgets", () => ({
18 createLiveActivity: vi.fn((name: string, layout: unknown) => ({ layout, name })),
19}));
20​
21import { AgentActivity, type AgentActivityProps } from "./AgentActivity";
22​
23const props = {
24 title: "T3 Code",
25 subtitle: "Agent work in progress",
26 activeCount: 1,
27 updatedAt: "2026-05-25T13:07:00.000Z",
28 activities: [],
29} satisfies AgentActivityProps;
30​
31const environment = {
32 colorScheme: "dark",
33 isLuminanceReduced: false,
34} as const;
35​
36describe("AgentActivity widget layout", () => {
37 it("formats its updated-at label without app-runtime helper references", () => {
38 expect(JSON.stringify(AgentActivity(props, environment as never))).toContain(
39 '"children":["Updated ","1:07"]',
40 );
41 expect(AgentActivity.toString()).not.toContain("formatAgentActivityUpdatedAtLabel");
42 });
43​
44 it("uses now when the updated-at timestamp is malformed", () => {
45 expect(
46 JSON.stringify(AgentActivity({ ...props, updatedAt: "not-a-date" }, environment as never)),
47 ).toContain('"children":["Updated ","now"]');
48 });
49});