the universal sandbox runtime for agents and humans.
pocketenv.io
sandbox
openclaw
agent
claude-code
vercel-sandbox
deno-sandbox
cloudflare-sandbox
atproto
sprites
daytona
1import { vi, describe, it, expect, beforeEach } from "vitest";
2import consola from "consola";
3import { Sandbox } from "@pocketenv/sdk";
4import whoami from "./whoami";
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(), getProfile: vi.fn() },
12}));
13
14describe("whoami", () => {
15 beforeEach(() => {
16 vi.clearAllMocks();
17 });
18
19 it("logs the current user profile", async () => {
20 vi.mocked(Sandbox.getProfile).mockResolvedValue({
21 handle: "testuser.bsky.social",
22 displayName: "Test User",
23 } as any);
24
25 await whoami();
26
27 expect(Sandbox.getProfile).toHaveBeenCalledOnce();
28 expect(consola.log).toHaveBeenCalledWith(
29 expect.stringContaining("@testuser.bsky.social"),
30 );
31 expect(consola.log).toHaveBeenCalledWith(
32 expect.stringContaining("Test User"),
33 );
34 });
35});