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 42 lines 1.1 kB view raw
1import { vi, describe, it, expect, beforeEach } from "vitest"; 2import consola from "consola"; 3import logout from "./logout"; 4 5vi.mock("consola", () => ({ 6 default: { log: vi.fn(), success: vi.fn(), error: vi.fn() }, 7})); 8vi.mock("node:fs/promises", () => ({ 9 default: { 10 access: vi.fn(), 11 unlink: vi.fn(), 12 }, 13})); 14 15import fs from "node:fs/promises"; 16 17describe("logout", () => { 18 beforeEach(() => { 19 vi.clearAllMocks(); 20 }); 21 22 it("deletes the token file and logs success", async () => { 23 vi.mocked(fs.access).mockResolvedValue(undefined); 24 vi.mocked(fs.unlink).mockResolvedValue(undefined); 25 26 await logout(); 27 28 expect(fs.unlink).toHaveBeenCalledOnce(); 29 expect(consola.log).toHaveBeenCalledWith("Logged out successfully"); 30 }); 31 32 it("logs success even if token file does not exist", async () => { 33 vi.mocked(fs.access).mockRejectedValue( 34 Object.assign(new Error("ENOENT"), { code: "ENOENT" }), 35 ); 36 37 await logout(); 38 39 expect(fs.unlink).not.toHaveBeenCalled(); 40 expect(consola.log).toHaveBeenCalledWith("Logged out successfully"); 41 }); 42});