Skip to content

Commit 7ff5e09

Browse files
committed
test: tighten nullable status assertions
1 parent f309a40 commit 7ff5e09

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎src/agents/anthropic-payload-log.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("createAnthropicPayloadLogger", () => {
1414
flush: async () => undefined,
1515
},
1616
});
17-
expect(logger).not.toBeNull();
17+
expect(typeof logger?.wrapStreamFn).toBe("function");
1818

1919
const payload = {
2020
messages: [
@@ -41,7 +41,11 @@ describe("createAnthropicPayloadLogger", () => {
4141
}) as StreamFn;
4242

4343
const wrapped = logger?.wrapStreamFn(streamFn);
44-
await wrapped?.({ api: "anthropic-messages" } as never, { messages: [] } as never, {});
44+
expect(typeof wrapped).toBe("function");
45+
if (!wrapped) {
46+
throw new Error("expected payload logger to wrap stream function");
47+
}
48+
await wrapped({ api: "anthropic-messages" } as never, { messages: [] } as never, {});
4549

4650
const event = JSON.parse(lines[0]?.trim() ?? "{}") as Record<string, unknown>;
4751
const sanitizedPayload = (event.payload ?? {}) as Record<string, unknown>;

‎src/agents/cache-trace.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("createCacheTrace", () => {
5353
},
5454
});
5555

56-
expect(trace).not.toBeNull();
56+
expect(typeof trace?.recordStage).toBe("function");
5757
expect(trace?.filePath).toBe(resolveUserPath("~/.openclaw/logs/cache-trace.jsonl"));
5858

5959
trace?.recordStage("session:loaded", {

‎src/agents/tools/music-generate-tool.status.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("createMusicGenerateTool status actions", () => {
4949
const result = createMusicGenerateDuplicateGuardResult("agent:main:discord:direct:123");
5050
const text = (result?.content?.[0] as { text: string } | undefined)?.text ?? "";
5151

52-
expect(result).not.toBeNull();
52+
expect(result?.content).toHaveLength(1);
5353
expect(text).toContain("Music generation task task-active is already running with google.");
5454
expect(text).toContain("Do not call music_generate again for this request.");
5555
expect(result?.details).toMatchObject({

‎src/agents/tools/video-generate-tool.status.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("createVideoGenerateTool status actions", () => {
4949
const result = createVideoGenerateDuplicateGuardResult("agent:main:discord:direct:123");
5050
const text = (result?.content?.[0] as { text: string } | undefined)?.text ?? "";
5151

52-
expect(result).not.toBeNull();
52+
expect(result?.content).toHaveLength(1);
5353
expect(text).toContain("Video generation task task-active is already running with openai.");
5454
expect(text).toContain("Do not call video_generate again for this request.");
5555
expect(result?.details).toMatchObject({

0 commit comments

Comments
 (0)