Skip to main content
The Deno 2 Release Candidate is here
Learn more
Latest
class CallableVerifier
import { CallableVerifier } from "https://deno.land/x/rhum@v2.2.0/src/verifiers/callable_verifier.ts";

Methods

protected
argsAsString(args: unknown[]): string

Make a user friendly version of the args. This is for display in the VerificationError stack trace. For example, the original args ...

[true, false, "hello"]

... becomes ...

true, false, "hello"

The above will ultimately end up in stack trace messages like:

.toBeCalledWith(true, false, "hello")

If we do not do this, then the following stack trace message will show, which is not really clear because the args are in an array and the "hello" string has its quotes missing:

.toBeCalledWith([true, false, hello])
protected
argsAsStringWithTypes(args: unknown[]): string

Same as this.argsAsString(), but add typings to the args. For example:

[true, false, "hello"]

... becomes ...

true<boolean>, false<boolean>, "hello"<string>
protected
getArgType(arg: unknown): string

Get the arg type in string format for the given arg.

protected
verifyToBeCalled(
actualCalls: number,
expectedCalls: number | undefined,
errorMessage: string,
codeThatThrew: string,
): void

Verify that the number of actual calls matches the number of expected calls.

protected
verifyToBeCalledWithArgsTooFewArgs(
actualArgs: unknown[],
expectedArgs: unknown[],
errorMessage: string,
codeThatThrew: string,
): void

Verify that the number of expected args is not less than the actual args.

protected
verifyToBeCalledWithArgsTooManyArgs(
actualArgs: unknown[],
expectedArgs: unknown[],
errorMessage: string,
codeThatThrew: string,
): void

Verify that the number of expected args is not more than the actual args.

protected
verifyToBeCalledWithArgsUnexpectedValues(
actualArgs: unknown[],
expectedArgs: unknown[],
errorMessage: string,
codeThatThrew: string,
): void

Verify that the expected args match the actual args by value and type.

protected
verifyToBeCalledWithoutArgs(
actualArgs: unknown[],
errorMessage: string,
codeThatThrew: string,
): this

Verify that the no args were used.