import { beforeEach, describe, expect, test } from "vitest"; import { MemoryStorage } from "../../src/auth/storage/MemoryStorage"; describe("MemoryStorage", () => { let storage: MemoryStorage; beforeEach(() => { storage = new MemoryStorage(); }); test("should return null for missing key", async () => { expect(await storage.get("missing")).toBeNull(); }); test("should set and get a value", async () => { await storage.set("key", "value"); expect(await storage.get("key")).toBe("value"); }); test("should overwrite existing value", async () => { await storage.set("key", "value1"); await storage.set("key", "value2"); expect(await storage.get("key")).toBe("value2"); }); test("should remove a value", async () => { await storage.set("key", "value"); await storage.remove("key"); expect(await storage.get("key")).toBeNull(); }); test("should not throw when removing missing key", async () => { await expect(storage.remove("missing")).resolves.not.toThrow(); }); test("should clear all values", async () => { await storage.set("a", "1"); await storage.set("b", "2"); storage.clear(); expect(await storage.get("a")).toBeNull(); expect(await storage.get("b")).toBeNull(); }); });