test: simplify twitch outbound chunk mock

This commit is contained in:
Peter Steinberger
2026-05-09 00:02:45 +01:00
parent 8e3848d215
commit 63b29b9ebf

View File

@@ -33,7 +33,7 @@ vi.mock("./send.js", () => ({
}));
vi.mock("./utils/markdown.js", () => ({
chunkTextForTwitch: vi.fn((text) => text.split(/(.{500})/).filter(Boolean)),
chunkTextForTwitch: vi.fn(chunkMockTextForTwitch),
}));
vi.mock("./utils/twitch.js", () => ({
@@ -42,6 +42,16 @@ vi.mock("./utils/twitch.js", () => ({
new Error(`Missing target for ${channel}. Provide ${hint}`),
}));
function chunkMockTextForTwitch(text: string): string[] {
const chunks: string[] = [];
for (const chunk of text.split(/(.{500})/)) {
if (chunk.length > 0) {
chunks.push(chunk);
}
}
return chunks;
}
function assertResolvedTarget(
result: ReturnType<NonNullable<typeof twitchOutbound.resolveTarget>>,
): string {