diff --git a/frontend/core/wizard/src/commonTest/kotlin/at/mocode/frontend/core/wizard/WizardRuntimeTest.kt b/frontend/core/wizard/src/commonTest/kotlin/at/mocode/frontend/core/wizard/WizardRuntimeTest.kt new file mode 100644 index 00000000..894e5537 --- /dev/null +++ b/frontend/core/wizard/src/commonTest/kotlin/at/mocode/frontend/core/wizard/WizardRuntimeTest.kt @@ -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) + } +} diff --git a/frontend/core/wizard/src/jvmTest/kotlin/at/mocode/frontend/core/wizard/WizardRuntimeJvmTest.kt b/frontend/core/wizard/src/jvmTest/kotlin/at/mocode/frontend/core/wizard/WizardRuntimeJvmTest.kt new file mode 100644 index 00000000..25d06a14 --- /dev/null +++ b/frontend/core/wizard/src/jvmTest/kotlin/at/mocode/frontend/core/wizard/WizardRuntimeJvmTest.kt @@ -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) + } +}