test: simplify twitch outbound chunk mock · openclaw/openclaw@63b29b9
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -33,7 +33,7 @@ vi.mock("./send.js", () => ({
|
33 | 33 | })); |
34 | 34 | |
35 | 35 | vi.mock("./utils/markdown.js", () => ({ |
36 | | -chunkTextForTwitch: vi.fn((text) => text.split(/(.{500})/).filter(Boolean)), |
| 36 | +chunkTextForTwitch: vi.fn(chunkMockTextForTwitch), |
37 | 37 | })); |
38 | 38 | |
39 | 39 | vi.mock("./utils/twitch.js", () => ({ |
@@ -42,6 +42,16 @@ vi.mock("./utils/twitch.js", () => ({
|
42 | 42 | new Error(`Missing target for ${channel}. Provide ${hint}`), |
43 | 43 | })); |
44 | 44 | |
| 45 | +function chunkMockTextForTwitch(text: string): string[] { |
| 46 | +const chunks: string[] = []; |
| 47 | +for (const chunk of text.split(/(.{500})/)) { |
| 48 | +if (chunk.length > 0) { |
| 49 | +chunks.push(chunk); |
| 50 | +} |
| 51 | +} |
| 52 | +return chunks; |
| 53 | +} |
| 54 | + |
45 | 55 | function assertResolvedTarget( |
46 | 56 | result: ReturnType<NonNullable<typeof twitchOutbound.resolveTarget>>, |
47 | 57 | ): string { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。