mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: simplify twitch outbound chunk mock
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user