From 71f7bd1cfd2448485e823f8f59a865d83a52d861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Abadesso?= Date: Fri, 23 Jan 2026 23:37:56 -0300 Subject: [PATCH] test: add tests for normalizePluginsConfig memory slot handling --- src/plugins/config-state.test.ts | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/plugins/config-state.test.ts diff --git a/src/plugins/config-state.test.ts b/src/plugins/config-state.test.ts new file mode 100644 index 000000000..c5c4924eb --- /dev/null +++ b/src/plugins/config-state.test.ts @@ -0,0 +1,52 @@ +import { describe, expect, it } from "vitest"; + +import { normalizePluginsConfig } from "./config-state.js"; + +describe("normalizePluginsConfig", () => { + it("uses default memory slot when not specified", () => { + const result = normalizePluginsConfig({}); + expect(result.slots.memory).toBe("memory-core"); + }); + + it("respects explicit memory slot value", () => { + const result = normalizePluginsConfig({ + slots: { memory: "custom-memory" }, + }); + expect(result.slots.memory).toBe("custom-memory"); + }); + + it("disables memory slot when set to 'none'", () => { + const result = normalizePluginsConfig({ + slots: { memory: "none" }, + }); + expect(result.slots.memory).toBeNull(); + }); + + it("disables memory slot when set to 'None' (case insensitive)", () => { + const result = normalizePluginsConfig({ + slots: { memory: "None" }, + }); + expect(result.slots.memory).toBeNull(); + }); + + it("trims whitespace from memory slot value", () => { + const result = normalizePluginsConfig({ + slots: { memory: " custom-memory " }, + }); + expect(result.slots.memory).toBe("custom-memory"); + }); + + it("uses default when memory slot is empty string", () => { + const result = normalizePluginsConfig({ + slots: { memory: "" }, + }); + expect(result.slots.memory).toBe("memory-core"); + }); + + it("uses default when memory slot is whitespace only", () => { + const result = normalizePluginsConfig({ + slots: { memory: " " }, + }); + expect(result.slots.memory).toBe("memory-core"); + }); +});