mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 16:20:21 +00:00
refactor(cli): share npm install metadata helpers
This commit is contained in:
32
src/cli/plugins-config.test.ts
Normal file
32
src/cli/plugins-config.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { setPluginEnabledInConfig } from "./plugins-config.js";
|
||||
|
||||
describe("setPluginEnabledInConfig", () => {
|
||||
it("sets enabled flag for an existing plugin entry", () => {
|
||||
const config = {
|
||||
plugins: {
|
||||
entries: {
|
||||
alpha: { enabled: false, custom: "x" },
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
const next = setPluginEnabledInConfig(config, "alpha", true);
|
||||
|
||||
expect(next.plugins?.entries?.alpha).toEqual({
|
||||
enabled: true,
|
||||
custom: "x",
|
||||
});
|
||||
});
|
||||
|
||||
it("creates a plugin entry when it does not exist", () => {
|
||||
const config = {} as OpenClawConfig;
|
||||
|
||||
const next = setPluginEnabledInConfig(config, "beta", false);
|
||||
|
||||
expect(next.plugins?.entries?.beta).toEqual({
|
||||
enabled: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user