Class: Tree

Tree.Tree

Represents the expected execution path of all ExpectedCalls.

Constructor

new Tree(node)

Creates a new Tree.Tree

Parameters:
Name Type Description
node Tree.AndNode | Tree.ExpectedCallNode

Inital node in this tree.

Source:

Members

_calls

Gets all ExpectedCalls in this tree.

Source:

_lastNode

Gets last non-Tree.TerminusNode node in this tree.

Source:

Methods

_callsAfter(node) → {Array.<ExpectedCall>}

Gets all ExpectedCalls that come after the specified node.

Parameters:
Name Type Description
node Tree.AndNode | Tree.ExpectedCallNode

Current node in the tree.

Source:
Returns:

List of expected calls that come after the specified node.

Type
Array.<ExpectedCall>

_chainNodes(a, b)

Chains two nodes together by making a the parent of b

Parameters:
Name Type Description
a Tree.Node

Node that will be the parent of b

b Tree.Node

Node that will be the child of a

Source:

_checkCalls()

Checks to see if all required ExpectedCalls in this tree were completed during execution.

Source:
Throws:

Will throw an error if any required expected calls are incomplete.

Type
Errors.NotAllCallsOccurredError

_executeNode(mock, args) → {object|undefined}

Attempts to execute a call to a Mock.

Parameters:
Name Type Description
mock Mock

Mock that was called.

args Array.<object>

Arguments for the call.

Source:
Throws:
Returns:

Will return a value if the mock as a return value; otherwise undefined.

Type
object | undefined

_resetMocks()

Resets all Mock globals and handlers

Source:

_setMockExecutionHandler()

Sets execution handlers of all Mocks in this tree to this trees Tree.Tree#executeNode.

Source:

and(tree)

Combines two execution Tree.Trees together via an AND operation.

Parameters:
Name Type Description
tree Tree.Tree

Tree to combine with this tree.

Source:

execute(thunk) → {Promise|undefined}

Executes the specifed test code.

Parameters:
Name Type Description
thunk function

Test code.

Source:
Returns:

Promise if thunk has a callback argument; otherwise undefined.

Type
Promise | undefined

ignoreOtherCalls()

Tells this tree to ignore unexpected and out of order calls during execution and focus only on the required ones.

Source:

then(tree)

Combines two execution Tree.Trees together via a THEN operation.

Parameters:
Name Type Description
tree Tree.Tree

Tree to combine with this tree.

Source:

toString() → {string}

Converts this tree into a string.

Source:
Returns:

This tree in string form.

Type
string