test: füge Unit-Tests für WizardRuntime hinzu
Signed-off-by: StefanMoCoAt <stefan.mo.co@gmail.com>
This commit is contained in:
parent
4692bd186c
commit
9556e0ac67
|
|
@ -0,0 +1,47 @@
|
|||
package at.mocode.frontend.core.wizard
|
||||
|
||||
import at.mocode.frontend.core.navigation.AppScreen
|
||||
import at.mocode.frontend.core.wizard.runtime.WizardContext
|
||||
import at.mocode.frontend.core.wizard.samples.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class WizardRuntimeTest {
|
||||
@Test
|
||||
fun next_goes_to_selection_when_hasZns_true() {
|
||||
val ctx = WizardContext(
|
||||
origin = AppScreen.Home,
|
||||
isOnline = true,
|
||||
stats = at.mocode.frontend.core.domain.repository.MasterdataStats(
|
||||
lastImport = null,
|
||||
vereinCount = 1,
|
||||
reiterCount = 0,
|
||||
pferdCount = 0,
|
||||
funktionaerCount = 0
|
||||
)
|
||||
)
|
||||
val state0 = demoStartState(AppScreen.Home)
|
||||
val state1 = DemoEventFlow.next(ctx, state0)
|
||||
assertEquals(DemoEventStep.VeranstalterSelection, state1.current)
|
||||
assertEquals(listOf(DemoEventStep.ZnsCheck), state1.history)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun back_returns_previous_when_history_exists() {
|
||||
val ctx = WizardContext(
|
||||
origin = AppScreen.Home,
|
||||
isOnline = true,
|
||||
stats = at.mocode.frontend.core.domain.repository.MasterdataStats(
|
||||
lastImport = null,
|
||||
vereinCount = 1,
|
||||
reiterCount = 0,
|
||||
pferdCount = 0,
|
||||
funktionaerCount = 0
|
||||
)
|
||||
)
|
||||
val s0 = demoStartState(AppScreen.Home)
|
||||
val s1 = DemoEventFlow.next(ctx, s0)
|
||||
val s2 = DemoEventFlow.back(s1)
|
||||
assertEquals(DemoEventStep.ZnsCheck, s2.current)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package at.mocode.frontend.core.wizard
|
||||
|
||||
import at.mocode.frontend.core.domain.repository.MasterdataStats
|
||||
import at.mocode.frontend.core.navigation.AppScreen
|
||||
import at.mocode.frontend.core.wizard.runtime.WizardContext
|
||||
import at.mocode.frontend.core.wizard.samples.DemoEventFlow
|
||||
import at.mocode.frontend.core.wizard.samples.DemoEventStep
|
||||
import at.mocode.frontend.core.wizard.samples.demoStartState
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class WizardRuntimeJvmTest {
|
||||
@Test
|
||||
fun next_goes_to_selection_when_hasZns_true() {
|
||||
val ctx = WizardContext(
|
||||
origin = AppScreen.Home,
|
||||
isOnline = true,
|
||||
stats = MasterdataStats(
|
||||
lastImport = null,
|
||||
vereinCount = 1,
|
||||
reiterCount = 0,
|
||||
pferdCount = 0,
|
||||
funktionaerCount = 0
|
||||
)
|
||||
)
|
||||
val state0 = demoStartState(AppScreen.Home)
|
||||
val state1 = DemoEventFlow.next(ctx, state0)
|
||||
assertEquals(DemoEventStep.VeranstalterSelection, state1.current)
|
||||
assertEquals(listOf(DemoEventStep.ZnsCheck), state1.history)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun back_returns_previous_when_history_exists() {
|
||||
val ctx = WizardContext(
|
||||
origin = AppScreen.Home,
|
||||
isOnline = true,
|
||||
stats = MasterdataStats(
|
||||
lastImport = null,
|
||||
vereinCount = 1,
|
||||
reiterCount = 0,
|
||||
pferdCount = 0,
|
||||
funktionaerCount = 0
|
||||
)
|
||||
)
|
||||
val s0 = demoStartState(AppScreen.Home)
|
||||
val s1 = DemoEventFlow.next(ctx, s0)
|
||||
val s2 = DemoEventFlow.back(s1)
|
||||
assertEquals(DemoEventStep.ZnsCheck, s2.current)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user