Function assertSpyCallAsync
- assert
Spy <Self, Args, Return>(spy, callIndex, expected?): Promise<void>Call Async Type Parameters
Parameters
Returns Promise<void>
Example: Usage
import { assertSpyCallAsync, spy } from "@std/testing/mock";
const func = spy((a: number, b: number) => new Promise((resolve) => {
setTimeout(() => resolve(a + b), 100)
}));
await func(3, 4);
await func(5, 6);
// asserts each call made to the spy function.
await assertSpyCallAsync(func, 0, { args: [3, 4], returned: 7 });
await assertSpyCallAsync(func, 1, { args: [5, 6], returned: 11 });
Asserts that an async spy is called as expected.