mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-29 09:41:08 +00:00
test(types): fix ts narrowing regressions in followup and matrix queue tests
This commit is contained in:
@@ -79,8 +79,11 @@ describe("enqueueSend", () => {
|
|||||||
await vi.advanceTimersByTimeAsync(DEFAULT_SEND_GAP_MS);
|
await vi.advanceTimersByTimeAsync(DEFAULT_SEND_GAP_MS);
|
||||||
const firstResult = await first;
|
const firstResult = await first;
|
||||||
expect(firstResult.ok).toBe(false);
|
expect(firstResult.ok).toBe(false);
|
||||||
|
if (firstResult.ok) {
|
||||||
|
throw new Error("expected first queue item to fail");
|
||||||
|
}
|
||||||
expect(firstResult.error).toBeInstanceOf(Error);
|
expect(firstResult.error).toBeInstanceOf(Error);
|
||||||
expect((firstResult.error as Error).message).toBe("boom");
|
expect(firstResult.error.message).toBe("boom");
|
||||||
|
|
||||||
const second = enqueueSend("!room:example.org", async () => "ok");
|
const second = enqueueSend("!room:example.org", async () => "ok");
|
||||||
await vi.advanceTimersByTimeAsync(DEFAULT_SEND_GAP_MS);
|
await vi.advanceTimersByTimeAsync(DEFAULT_SEND_GAP_MS);
|
||||||
@@ -110,6 +113,9 @@ describe("enqueueSend", () => {
|
|||||||
gate.resolve();
|
gate.resolve();
|
||||||
const firstResult = await first;
|
const firstResult = await first;
|
||||||
expect(firstResult.ok).toBe(false);
|
expect(firstResult.ok).toBe(false);
|
||||||
|
if (firstResult.ok) {
|
||||||
|
throw new Error("expected head queue item to fail");
|
||||||
|
}
|
||||||
expect(firstResult.error).toBeInstanceOf(Error);
|
expect(firstResult.error).toBeInstanceOf(Error);
|
||||||
|
|
||||||
await vi.advanceTimersByTimeAsync(DEFAULT_SEND_GAP_MS);
|
await vi.advanceTimersByTimeAsync(DEFAULT_SEND_GAP_MS);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ const baseQueuedRun = (messageProvider = "whatsapp"): FollowupRun =>
|
|||||||
}) as FollowupRun;
|
}) as FollowupRun;
|
||||||
|
|
||||||
function createQueuedRun(
|
function createQueuedRun(
|
||||||
overrides: Partial<FollowupRun> & { run?: Partial<FollowupRun["run"]> } = {},
|
overrides: Partial<Omit<FollowupRun, "run">> & { run?: Partial<FollowupRun["run"]> } = {},
|
||||||
): FollowupRun {
|
): FollowupRun {
|
||||||
const base = baseQueuedRun();
|
const base = baseQueuedRun();
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user