mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 20:02:56 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
@@ -3,6 +3,25 @@ import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveHeartbeatVisibility } from "./heartbeat-visibility.js";
|
||||
|
||||
describe("resolveHeartbeatVisibility", () => {
|
||||
function createTelegramAccountHeartbeatConfig(): OpenClawConfig {
|
||||
return {
|
||||
channels: {
|
||||
telegram: {
|
||||
heartbeat: {
|
||||
showOk: true,
|
||||
},
|
||||
accounts: {
|
||||
primary: {
|
||||
heartbeat: {
|
||||
showOk: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
}
|
||||
|
||||
it("returns default values when no config is provided", () => {
|
||||
const cfg = {} as OpenClawConfig;
|
||||
const result = resolveHeartbeatVisibility({ cfg, channel: "telegram" });
|
||||
@@ -136,46 +155,14 @@ describe("resolveHeartbeatVisibility", () => {
|
||||
});
|
||||
|
||||
it("handles missing accountId gracefully", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
telegram: {
|
||||
heartbeat: {
|
||||
showOk: true,
|
||||
},
|
||||
accounts: {
|
||||
primary: {
|
||||
heartbeat: {
|
||||
showOk: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
const cfg = createTelegramAccountHeartbeatConfig();
|
||||
const result = resolveHeartbeatVisibility({ cfg, channel: "telegram" });
|
||||
|
||||
expect(result.showOk).toBe(true);
|
||||
});
|
||||
|
||||
it("handles non-existent account gracefully", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
telegram: {
|
||||
heartbeat: {
|
||||
showOk: true,
|
||||
},
|
||||
accounts: {
|
||||
primary: {
|
||||
heartbeat: {
|
||||
showOk: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
const cfg = createTelegramAccountHeartbeatConfig();
|
||||
const result = resolveHeartbeatVisibility({
|
||||
cfg,
|
||||
channel: "telegram",
|
||||
|
||||
Reference in New Issue
Block a user