MiddlewareTestScope

The scope for a middleware under test.

Functions

Link copied to clipboard
abstract fun clearActionsHistory()

Clears history and unverified.

Link copied to clipboard
abstract fun onDispatch(block: MutableDispatchScope<State>.(Action) -> Unit)

Sets a block that will be called on every dispatch called by component under test. Each call replaces previously provided block.

Link copied to clipboard
abstract fun onNext(block: MutableDispatchScope<State>.(Action) -> Unit)

Just like onDispatch, but for MiddlewareScope.next function.

Link copied to clipboard
abstract fun testAction(action: Action)

Calls middleware under test with given action.

Link copied to clipboard
abstract fun verifyNext(block: ActionsAssertScope.() -> Unit)

Runs assertions block on actions passed to the next middleware by the middleware under test.

Properties

Link copied to clipboard
abstract var closure: DispatchClosure
Link copied to clipboard
abstract var currentState: State
Link copied to clipboard
abstract val history: List<Action>

Contains all dispatched actions history.

Link copied to clipboard
abstract val unverified: Queue<Action>

Contains all unverified dispatched actions queue. If action is verified, it must be pulled from this queue.

Extensions

Link copied to clipboard

Returns a string that contains list of all dispatched actions. The action recently pulled form the queue is marked with '->'.

Link copied to clipboard

Asserts that first unverified action is equal to action.

Link copied to clipboard
inline fun <T : Action> ActionsAssertScope.assertActionOfType(assertions: (T) -> Unit = {})

Asserts that first unverified action is an instance of type T. Also, it applies additional assertions.

Link copied to clipboard

Asserts that there are only actions dispatched in given order and no more.

Link copied to clipboard

Asserts that all dispatched actions count is equal to count. It does not pull any action from unverified queue.

Link copied to clipboard
fun ActionsAssertScope.assertEveryAction(message: String? = null, predicate: (Action) -> Boolean)

Asserts that every unverified action matches the predicate.

Link copied to clipboard

Asserts that there is no dispatched actions.

Link copied to clipboard

Asserts that there is no unverified actions left.

Link copied to clipboard

Asserts that first unverified action is equal to action and it is the only one dispatched action.

Link copied to clipboard
inline fun <T : Action> ActionsAssertScope.assertSingleActionOfType(assertions: (T) -> Unit = {})

Asserts that first unverified action is an instance of T and it is the only one dispatched action. Also, it applies additional assertions.

Link copied to clipboard

Returns first unverified action.

Link copied to clipboard

Prints information about dispatched actions based on actionStackString.

Link copied to clipboard

Skips first n unverified actions.

Link copied to clipboard

Skips actions while predicate is true.

Link copied to clipboard

Skips first unverified action.

Link copied to clipboard

Skips all unverified actions.

Link copied to clipboard
fun MiddlewareTestScope<*>.testAllActions(vararg actions: Action)

Calls MiddlewareTestScope.testAction for every action from actions.

Link copied to clipboard

Calls middleware under test with given action and joins foreground job.

Link copied to clipboard
fun MiddlewareTestScope<*>.testJobActionIn(scope: CoroutineScope, action: ForegroundJobAction): Job

Calls middleware under test with given action and provides a scope for a foreground job.