the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 68 lines 1.8 kB view raw
1import { vi, describe, it, expect, beforeEach } from "vitest"; 2import consola from "consola"; 3import { Sandbox } from "@pocketenv/sdk"; 4import listSandboxes from "./list"; 5 6vi.mock("../lib/sdk", () => ({ configureSdk: vi.fn() })); 7vi.mock("../theme", () => ({ 8 c: { 9 primary: (s: string | number) => String(s), 10 secondary: (s: string | number) => String(s), 11 highlight: (s: string | number) => String(s), 12 }, 13})); 14vi.mock("consola", () => ({ 15 default: { log: vi.fn(), success: vi.fn(), error: vi.fn() }, 16})); 17vi.mock("@pocketenv/sdk", () => ({ 18 Sandbox: { get: vi.fn(), list: vi.fn(), configure: vi.fn() }, 19})); 20 21describe("listSandboxes", () => { 22 beforeEach(() => { 23 vi.clearAllMocks(); 24 }); 25 26 it("fetches sandboxes and logs a table", async () => { 27 vi.mocked(Sandbox.list).mockResolvedValue({ 28 sandboxes: [ 29 { 30 name: "my-sandbox", 31 baseSandbox: "base", 32 status: "RUNNING", 33 createdAt: new Date().toISOString(), 34 }, 35 ], 36 } as any); 37 38 await listSandboxes(); 39 40 expect(Sandbox.list).toHaveBeenCalledWith({ limit: 100, offset: 0 }); 41 expect(consola.log).toHaveBeenCalledOnce(); 42 }); 43 44 it("logs an empty table when no sandboxes exist", async () => { 45 vi.mocked(Sandbox.list).mockResolvedValue({ sandboxes: [] } as any); 46 47 await listSandboxes(); 48 49 expect(consola.log).toHaveBeenCalledOnce(); 50 }); 51 52 it("renders STOPPED status without highlight", async () => { 53 vi.mocked(Sandbox.list).mockResolvedValue({ 54 sandboxes: [ 55 { 56 name: "stopped-sandbox", 57 baseSandbox: null, 58 status: "STOPPED", 59 createdAt: new Date().toISOString(), 60 }, 61 ], 62 } as any); 63 64 await listSandboxes(); 65 66 expect(consola.log).toHaveBeenCalledOnce(); 67 }); 68});