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 54 lines 1.5 kB view raw
1import { vi, describe, it, expect, beforeEach } from "vitest"; 2import consola from "consola"; 3import { Sandbox } from "@pocketenv/sdk"; 4import { exposeVscode } from "./vscode"; 5 6vi.mock("../lib/sdk", () => ({ configureSdk: vi.fn() })); 7vi.mock("../theme", () => ({ 8 c: { 9 primary: (s: string | number) => String(s), 10 }, 11})); 12vi.mock("consola", () => ({ 13 default: { log: vi.fn(), success: vi.fn(), error: vi.fn() }, 14})); 15vi.mock("@pocketenv/sdk", () => ({ 16 Sandbox: { get: vi.fn(), configure: vi.fn() }, 17})); 18 19describe("exposeVscode", () => { 20 const mockExit = vi 21 .spyOn(process, "exit") 22 .mockImplementation(() => undefined as never); 23 24 beforeEach(() => { 25 vi.clearAllMocks(); 26 }); 27 28 it("exposes VS Code and logs success", async () => { 29 const mockSandbox = { 30 vscode: vi.fn().mockResolvedValue(undefined), 31 }; 32 vi.mocked(Sandbox.get).mockResolvedValue(mockSandbox as any); 33 34 await exposeVscode("my-sandbox"); 35 36 expect(Sandbox.get).toHaveBeenCalledWith("my-sandbox"); 37 expect(mockSandbox.vscode).toHaveBeenCalledOnce(); 38 expect(consola.success).toHaveBeenCalledWith( 39 expect.stringContaining("my-sandbox"), 40 ); 41 }); 42 43 it("logs error and exits on failure", async () => { 44 vi.mocked(Sandbox.get).mockRejectedValue(new Error("API error")); 45 46 await exposeVscode("my-sandbox"); 47 48 expect(consola.error).toHaveBeenCalledWith( 49 "Failed to expose VS Code:", 50 expect.any(Error), 51 ); 52 expect(mockExit).toHaveBeenCalledWith(1); 53 }); 54});