@@ -3,9 +3,9 @@ package com.squareup.workflow1.testing
3
3
import app.cash.turbine.ReceiveTurbine
4
4
import app.cash.turbine.test
5
5
import com.squareup.workflow1.RuntimeConfig
6
- import com.squareup.workflow1.RuntimeConfigOptions
7
6
import com.squareup.workflow1.Workflow
8
7
import com.squareup.workflow1.WorkflowInterceptor
8
+ import com.squareup.workflow1.config.JvmTestRuntimeConfigTools
9
9
import com.squareup.workflow1.renderWorkflowIn
10
10
import com.squareup.workflow1.testing.WorkflowTurbine.Companion.WORKFLOW_TEST_DEFAULT_TIMEOUT_MS
11
11
import kotlinx.coroutines.CoroutineScope
@@ -22,8 +22,8 @@ import kotlin.coroutines.CoroutineContext
22
22
import kotlin.time.Duration.Companion.milliseconds
23
23
24
24
/* *
25
- * This is a test harness to run integration tests for a Workflow tree. The parameters passed here are
26
- * the same as those to start a Workflow runtime with [renderWorkflowIn] except for ignoring
25
+ * This is a test harness to run turbine like tests for a Workflow tree. The parameters passed here
26
+ * are the same as those to start a Workflow runtime with [renderWorkflowIn] except for ignoring
27
27
* state persistence as that is not needed for this style of test.
28
28
*
29
29
* The [coroutineContext] rather than a [CoroutineScope] is passed so that this harness handles the
@@ -35,13 +35,15 @@ import kotlin.time.Duration.Companion.milliseconds
35
35
* This will start the Workflow runtime (with params as passed) rooted at whatever Workflow
36
36
* it is called on and then create a [WorkflowTurbine] for its renderings and run [testCase] on that.
37
37
* [testCase] can thus drive the test scenario and assert against renderings.
38
+ *
39
+ * The default [RuntimeConfig] will be the one specified via [JvmTestRuntimeConfigTools].
38
40
*/
39
41
@OptIn(ExperimentalCoroutinesApi ::class )
40
- public fun <PropsT , OutputT , RenderingT > Workflow <PropsT , OutputT , RenderingT >.headlessIntegrationTest (
42
+ public fun <PropsT , OutputT , RenderingT > Workflow <PropsT , OutputT , RenderingT >.renderForTest (
41
43
props : StateFlow <PropsT >,
42
44
coroutineContext : CoroutineContext = UnconfinedTestDispatcher (),
43
45
interceptors : List <WorkflowInterceptor > = emptyList(),
44
- runtimeConfig : RuntimeConfig = RuntimeConfigOptions . DEFAULT_CONFIG ,
46
+ runtimeConfig : RuntimeConfig = JvmTestRuntimeConfigTools .getTestRuntimeConfig() ,
45
47
onOutput : suspend (OutputT ) -> Unit = {},
46
48
testTimeout : Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS ,
47
49
testCase : suspend WorkflowTurbine <RenderingT >.() -> Unit
@@ -82,18 +84,18 @@ public fun <PropsT, OutputT, RenderingT> Workflow<PropsT, OutputT, RenderingT>.h
82
84
}
83
85
84
86
/* *
85
- * Version of [headlessIntegrationTest ] that does not require props. For Workflows that have [Unit]
87
+ * Version of [renderForTest ] that does not require props. For Workflows that have [Unit]
86
88
* props type.
87
89
*/
88
90
@OptIn(ExperimentalCoroutinesApi ::class )
89
- public fun <OutputT , RenderingT > Workflow <Unit , OutputT , RenderingT >.headlessIntegrationTest (
91
+ public fun <OutputT , RenderingT > Workflow <Unit , OutputT , RenderingT >.renderForTest (
90
92
coroutineContext : CoroutineContext = UnconfinedTestDispatcher (),
91
93
interceptors : List <WorkflowInterceptor > = emptyList(),
92
- runtimeConfig : RuntimeConfig = RuntimeConfigOptions . DEFAULT_CONFIG ,
94
+ runtimeConfig : RuntimeConfig = JvmTestRuntimeConfigTools .getTestRuntimeConfig() ,
93
95
onOutput : suspend (OutputT ) -> Unit = {},
94
96
testTimeout : Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS ,
95
97
testCase : suspend WorkflowTurbine <RenderingT >.() -> Unit
96
- ): Unit = headlessIntegrationTest (
98
+ ): Unit = renderForTest (
97
99
props = MutableStateFlow (Unit ).asStateFlow(),
98
100
coroutineContext = coroutineContext,
99
101
interceptors = interceptors,
0 commit comments