expectWorkflow

inline fun <ChildRenderingT, PropsT, StateT, OutputT, RenderingT> RenderTester<PropsT, StateT, OutputT, RenderingT>.expectWorkflow(identifier: WorkflowIdentifier, rendering: ChildRenderingT, key: String = "", description: String = "", noinline assertProps: (props: Any?) -> Unit = {}): RenderTester<PropsT, StateT, OutputT, RenderingT>(source)

Specifies that this render pass is expected to render a particular child workflow.

Workflow identifiers are compared taking the type hierarchy into account. When a workflow is rendered, it will match any expectation that specifies the type of that workflow, or any of its supertypes. This means that if you have a workflow that is split into an interface and a concrete class, your render tests can pass the class of the interface to this method instead of the actual class that implements it.

Note that Workflow is not a sub-type of Workflow because it is not covariant for the OutputT generic (the same is true for PropsT). This means that you cannot use the WorkflowIdentifier or KClass of a Workflow class whose OutputT or PropsT are supertypes to the one you want to match. If this is the only reasonable class definition you have access to, then consider using expectCovariantWorkflow and specifying those types explicitly.

Expecting impostor workflows

If the workflow-under-test renders an ImpostorWorkflow, the match will not be performed using the impostor type, but rather the real identifier of the impostor's WorkflowIdentifier. This will be the last identifier in the chain of impostor workflows' realIdentifiers.

A workflow that is wrapped multiple times by various operators will be matched on the upstream workflow, so for example the following expectation would succeed:

val workflow = Workflow.stateless<…> {
  renderChild(
    childWorkflow.mapRendering { … }
      .mapOutput { … }
  )
}

workflow.testRender(…)
  .expectWorkflow(childWorkflow::class, …)

Parameters

identifier

The WorkflowIdentifier of the expected workflow. May identify any supertype of the actual rendered workflow, e.g. if the workflow type is an interface and the workflow-under-test injects a fake.

rendering

The rendering to return from renderChild when this workflow is rendered.

key

The key passed to renderChild when rendering this workflow.

assertProps

A function that performs assertions on the props passed to renderChild.

description

Optional string that will be used to describe this expectation in error messages.


Specifies that this render pass is expected to render a particular child workflow.

Workflow identifiers are compared taking the type hierarchy into account. When a workflow is rendered, it will match any expectation that specifies the type of that workflow, or any of its supertypes. This means that if you have a workflow that is split into an interface and a concrete class, your render tests can pass the class of the interface to this method instead of the actual class that implements it.

Note that Workflow is not a sub-type of Workflow because it is not covariant for the OutputT generic (the same is true for PropsT). This means that you cannot use the WorkflowIdentifier or KClass of a Workflow class whose OutputT or PropsT are supertypes to the one you want to match. If this is the only reasonable class definition you have access to, then consider using expectCovariantWorkflow and specifying those types explicitly.

Expecting impostor workflows

If the workflow-under-test renders an ImpostorWorkflow, the match will not be performed using the impostor type, but rather the real identifier of the impostor's WorkflowIdentifier. This will be the last identifier in the chain of impostor workflows' realIdentifiers.

A workflow that is wrapped multiple times by various operators will be matched on the upstream workflow, so for example the following expectation would succeed:

val workflow = Workflow.stateless<…> {
  renderChild(
    childWorkflow.mapRendering { … }
      .mapOutput { … }
  )
}

workflow.testRender(…)
  .expectWorkflow(childWorkflow::class, …)

Parameters

identifier

The WorkflowIdentifier of the expected workflow. May identify any supertype of the actual rendered workflow, e.g. if the workflow type is an interface and the workflow-under-test injects a fake.

rendering

The rendering to return from renderChild when this workflow is rendered.

key

The key passed to renderChild when rendering this workflow.

assertProps

A function that performs assertions on the props passed to renderChild.

output

If non-null, WorkflowOutput.value will be "emitted" when this workflow is rendered. The WorkflowAction used to handle this output can be verified using methods on RenderTestResult.

description

Optional string that will be used to describe this expectation in error messages.


Specifies that this render pass is expected to render a particular child workflow.

Workflow identifiers are compared taking the type hierarchy into account. When a workflow is rendered, it will match any expectation that specifies the type of that workflow, or any of its supertypes. This means that if you have a workflow that is split into an interface and a concrete class, your render tests can pass the class of the interface to this method instead of the actual class that implements it.

Note that Workflow is not a sub-type of Workflow because it is not covariant for the OutputT generic (the same is true for PropsT). This means that you cannot use the WorkflowIdentifier or KClass of a Workflow class whose OutputT or PropsT are supertypes to the one you want to match. If this is the only reasonable class definition you have access to, then consider using expectCovariantWorkflow and specifying those types explicitly.

Expecting impostor workflows

If the workflow-under-test renders an ImpostorWorkflow, the match will not be performed using the impostor type, but rather the real identifier of the impostor's WorkflowIdentifier. This will be the last identifier in the chain of impostor workflows' realIdentifiers.

A workflow that is wrapped multiple times by various operators will be matched on the upstream workflow, so for example the following expectation would succeed:

val workflow = Workflow.stateless<…> {
  renderChild(childWorkflow.mapRendering { … })
}

workflow.testRender(…)
  .expectWorkflow(childWorkflow::class, …)

Parameters

workflowType

The KClass of the expected workflow. May also be any of the supertypes of the expected workflow, e.g. if the workflow type is an interface and the workflow-under-test injects a fake. See note above about covariance with PropsT and OutputT and how these cannot help with supertypes.

rendering

The rendering to return from renderChild when this workflow is rendered.

key

The key passed to renderChild when rendering this workflow.

assertProps

A function that performs assertions on the props passed to renderChild.

output

If non-null, WorkflowOutput.value will be "emitted" when this workflow is rendered. The WorkflowAction used to handle this output can be verified using methods on RenderTestResult.

description

Optional string that will be used to describe this expectation in error messages.