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 48 lines 1.5 kB view raw
1import { vi, describe, it, expect, beforeEach } from "vitest"; 2import consola from "consola"; 3import { Sandbox } from "@pocketenv/sdk"; 4import deleteSandbox from "./rm"; 5 6vi.mock("../lib/sdk", () => ({ configureSdk: vi.fn() })); 7vi.mock("consola", () => ({ 8 default: { log: vi.fn(), success: vi.fn(), error: vi.fn() }, 9})); 10vi.mock("@pocketenv/sdk", () => ({ 11 Sandbox: { get: vi.fn(), configure: vi.fn() }, 12})); 13 14describe("deleteSandbox", () => { 15 beforeEach(() => { 16 vi.clearAllMocks(); 17 }); 18 19 it("deletes a sandbox and logs success", async () => { 20 const mockSandbox = { delete: vi.fn().mockResolvedValue(undefined) }; 21 vi.mocked(Sandbox.get).mockResolvedValue(mockSandbox as any); 22 23 await deleteSandbox("my-sandbox"); 24 25 expect(Sandbox.get).toHaveBeenCalledWith("my-sandbox"); 26 expect(mockSandbox.delete).toHaveBeenCalledOnce(); 27 expect(consola.success).toHaveBeenCalledWith("Sandbox deleted successfully"); 28 }); 29 30 it("logs an error when deletion fails", async () => { 31 vi.mocked(Sandbox.get).mockRejectedValue(new Error("Not found")); 32 33 await deleteSandbox("my-sandbox"); 34 35 expect(consola.error).toHaveBeenCalledWith("Failed to delete sandbox"); 36 }); 37 38 it("logs an error when delete() throws", async () => { 39 const mockSandbox = { 40 delete: vi.fn().mockRejectedValue(new Error("Delete failed")), 41 }; 42 vi.mocked(Sandbox.get).mockResolvedValue(mockSandbox as any); 43 44 await deleteSandbox("my-sandbox"); 45 46 expect(consola.error).toHaveBeenCalledWith("Failed to delete sandbox"); 47 }); 48});