Class: ExpectedCall

ExpectedCall

Represents an expected call to a Mock.

Constructor

new ExpectedCall(mock, args, required, checkArgs)

Creates a new ExpectedCall

Parameters:
Name Type Description
mock Mock

Mock that will be called.

args Array.<object>

Arguments that are expected to be used during execution.

required boolean

If true the mock is required to be call during execution; other wise it is optional and can be skipped.

checkArgs boolean

If true then the arguments passed to the mock should be checked; otherwise they are ignored.

Source:

Members

actualArgs :Array.<object>

The arguments this expected call received during execution.

Type:
  • Array.<object>
Source:

callbackArgs :Array.<object>

If this expected call will invoke a callback these are the arguments that will be passed to it.

Type:
  • Array.<object>
Source:

callbackIndex :number

If this expected call will invoke a callback this will be the index of that callback in the arguments array that is passed to it at runtime.

Type:
  • number
Source:

checkArgs :boolean

Whether or not to check the arguments for this expected call during execution.

Type:
  • boolean
Source:

completed :boolean

Whether or not this expected call was called during execution.

Type:
  • boolean
Source:

expectedArgs :Array.<object>

The arguments this expected call expects during execution.

Type:
  • Array.<object>
Source:

mock :Mock

Mock this expected call is based on.

Type:
Source:

name

Gets the name of this expected calls mock.

Source:

required :boolean

Whether or not this expected call is required during execution.

Type:
  • boolean
Source:

returnValue :Error

This expected calls return value.

Type:
  • Error
Source:

returnValue :object

This expected calls return value.

Type:
  • object
Source:

Methods

execute(args)

Completes this expected call with the specified arguments.

Parameters:
Name Type Description
args Array.<object>

Arguments that were used during execution.

Source:

matches(mock, args) → {boolean}

Checks to see if the specified Mock and arguments match this expected call.

Parameters:
Name Type Description
mock Mock

Mock to compare against this expected calls mock.

args Array.<object>

Arguments to compare against this expected calls expected arguments.

Source:
Returns:

True if the mock and arguments match this expected call; otherwise false.

Type
boolean

matchesArguments(args) → {boolean}

Checks to see if the specified arguments match this expected calls expected arguments.

Parameters:
Name Type Description
args Array.<object>

Arguments to compare against this expected calls expected arguments.

Source:
Returns:

True if the arguments match the expected arguments; otherwise false.

Type
boolean

matchesFunction(mock) → {boolean}

Checks to see if the specified Mock is this expected calls mock.

Parameters:
Name Type Description
mock Mock

Mock to compare against this expected calls mock.

Source:
Returns:

True if the mocks are the same mock; otherwise false.

Type
boolean