* Asserts that the next call in sequence has the correct name and matches expected arguments. * Increments the internal call index.
(
name: string,
expectedArgs?: Record<string, unknown>,
)
| 63 | * Increments the internal call index. |
| 64 | */ |
| 65 | assertNextCall( |
| 66 | name: string, |
| 67 | expectedArgs?: Record<string, unknown>, |
| 68 | ): CapturedFunctionCall { |
| 69 | const call = this.calls[this.nextCallIndex]; |
| 70 | assert.ok( |
| 71 | call, |
| 72 | `Expected call at index ${this.nextCallIndex} (name: '${name}') to exist`, |
| 73 | ); |
| 74 | assert.strictEqual( |
| 75 | call.name, |
| 76 | name, |
| 77 | `Expected call at index ${this.nextCallIndex} to be '${name}', but got '${call.name}'`, |
| 78 | ); |
| 79 | |
| 80 | if (expectedArgs) { |
| 81 | for (const entry of Object.entries(expectedArgs)) { |
| 82 | const key = entry[0]; |
| 83 | const value = entry[1]; |
| 84 | assert.deepStrictEqual( |
| 85 | call.args[key], |
| 86 | value, |
| 87 | `Expected argument '${key}' on call '${name}' to be ${JSON.stringify(value)}, got ${JSON.stringify(call.args[key])}`, |
| 88 | ); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | this.nextCallIndex++; |
| 93 | return call; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | export interface TestScenario { |
no outgoing calls
no test coverage detected