Skip to content

//workflow/com.squareup.workflow1.testing/expectWorkflow

expectWorkflow

[jvm]
Content
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>
More info

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.

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

jvm

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.

[jvm]
Content
fun <ChildOutputT, ChildRenderingT, PropsT, StateT, OutputT, RenderingT> RenderTester<PropsT, StateT, OutputT, RenderingT>.expectWorkflow(identifier: WorkflowIdentifier, rendering: ChildRenderingT, output: WorkflowOutput<ChildOutputT>?, key: String = “”, description: String = “”, assertProps: (props: Any?) -> Unit = {}): RenderTester<PropsT, StateT, OutputT, RenderingT>
More info

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.

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

jvm

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.

[jvm]
Content
inline fun <ChildPropsT, ChildOutputT, ChildRenderingT, PropsT, StateT, OutputT, RenderingT> RenderTester<PropsT, StateT, OutputT, RenderingT>.expectWorkflow(workflowType: KClass<out Workflow<ChildPropsT, ChildOutputT, ChildRenderingT>>, rendering: ChildRenderingT, key: String = “”, crossinline assertProps: (ChildPropsT) -> Unit = {}, output: WorkflowOutput<ChildOutputT>? = null, description: String = “”): RenderTester<PropsT, StateT, OutputT, RenderingT>
More info

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.

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

jvm

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.

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.