assertSpyCallArg

import { assertSpyCallArg } from "jsr:@ende/testing/mock";

function

function assertSpyCallArg<Self, Args extends unknown[], Return, ExpectedArg>(spy: SpyLike<Self, Args, Return>, callIndex: number, argIndex: number, expected: ExpectedArg): ExpectedArg

Asserts that a spy is called with a specific arg as expected.

spy: SpyLike<Self, Args, Return>

The spy to check.

callIndex: number

The index of the call to check.

argIndex: number

The index of the arguments to check.

expected: ExpectedArg

The expected argument.

Returns

The actual argument.

Example: Usage

import { assertSpyCallArg, spy } from "@ende/testing/mock";

const func = spy((a: number, b: number) => a + b);

func(3, 4);
func(5, 6);

// asserts each call made to the spy function.
assertSpyCallArg(func, 0, 0, 3);
assertSpyCallArg(func, 0, 1, 4);
assertSpyCallArg(func, 1, 0, 5);
assertSpyCallArg(func, 1, 1, 6);

Source