Skip to content

Commit a78a06f

Browse files
committed
Adds test
1 parent 8b92031 commit a78a06f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,19 @@ class SiteCreationMainVMTest : BaseUnitTest() {
364364
verify(tracker, times(1)).trackSiteCreationAccessed(SiteCreationSource.UNSPECIFIED)
365365
}
366366

367+
@Test
368+
fun `given instance state returns an invalid step, when start, then site creation is reset`() {
369+
val expectedState = SiteCreationState(segmentId = SEGMENT_ID)
370+
whenever(savedInstanceState.getParcelableCompat<SiteCreationState>(KEY_SITE_CREATION_STATE))
371+
.thenReturn(expectedState)
372+
whenever(savedInstanceState.getInt(KEY_CURRENT_STEP)).thenReturn(-1) // Invalid step
373+
374+
val newViewModel = getNewViewModel()
375+
newViewModel.start(savedInstanceState, SiteCreationSource.UNSPECIFIED)
376+
377+
verify(wizardManager).setCurrentStepIndex(0)
378+
}
379+
367380
private fun currentWizardState(vm: SiteCreationMainVM) = vm.navigationTargetObservable.lastEvent!!.wizardState
368381

369382
private fun getNewViewModel() = SiteCreationMainVM(

0 commit comments

Comments
 (0)