Class: Expectation

Expectation

This is a transitional object that helps convert Mocks into ExpectedCalls and build the resulting execution Tree.Tree.

Constructor

new Expectation(mock, required)

Creates a new Expectation

Parameters:
Name Type Description
mock Mock

Mock that is being expected.

required boolean

If true then mock is required to be called; otherwise it is optional and may be skipped during execution.

Source:

Methods

after()

Alias for Expectation#when

Source:

and(expectation) → {Expectation}

Combines this expecation with the specifed expectation using AND. This means execution order does not matter and these expecations can be executed in either order.

Parameters:
Name Type Description
expectation Expectation

Expectation to combine with this expecatation.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

andAlso()

Alias for Expectation#and

Source:

andOtherCallsShouldBeIgnored() → {Expectation}

Makes it so that unexpected calls and out of order calls are ignored and only required calls are checked during execution.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

andThen()

Alias for Expectation#then

Source:

andWillCallback() → {Expectation}

Updates this expectations ExpectedCall to invoke a callback.

Parameters:
Name Type Attributes Description
...args Array.<object> <optional>

Arguments that will be passed to the callback when it is invoked.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

andWillReturn(returnValue) → {Expectation}

Updates this expectatations ExpectedCall to return the specified value.

Parameters:
Name Type Description
returnValue object

Value that will be returned when the expected call is executed.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

andWillThrow(error) → {Expectation}

Updates this expectatations ExpectedCall to throw the specified error.

Parameters:
Name Type Description
error Error

Error that will be thrown when the expected call is executed.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

multipleTimes(count) → {Expectation}

Clones this expectation so that is is expected the specified number of times.

Parameters:
Name Type Description
count number

Number of times this expecation should be expected.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

then(expectation) → {Expectation}

Combines this expecation with the specifed expectation using THEN. This means execution order matters and this expectation must come before the other.

Parameters:
Name Type Description
expectation Expectation

Expectation to combine with this expecatation.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

when(thunk)

Executes the test code and verifies the expectations that were built up.

Parameters:
Name Type Description
thunk function

Test code.

Source:

withAnyArguments() → {Expectation}

Updates this expectatations ExpectedCall to allow any arguments when it is called.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation

withOtherCallsIgnored()

Source:

withTheseArguments(arguments) → {Expectation}

Updates this expectatations ExpectedCall to have the specified arguments when it is called.

Parameters:
Name Type Description
arguments Array.<object>

Required arguments for the Mocks call.

Source:
Returns:

This expectation, which allows chaining.

Type
Expectation