Test poll view state without enough options.

This commit is contained in:
Onuray Sahin 2022-06-13 15:54:33 +03:00
parent 19de21535b
commit 5b35534c3d

View file

@ -54,4 +54,29 @@ class CreatePollViewModelTest {
.assertState(initialCreatePollViewState)
.finish()
}
@Test
fun `given there is not any options when the question is added then poll cannot be created and options can be added`() {
val createPollViewModel = createPollViewModel(PollMode.CREATE)
createPollViewModel.handle(CreatePollAction.OnQuestionChanged(fakeQuestion))
createPollViewModel
.test()
.assertState(pollViewStateWithOnlyQuestion)
.finish()
}
@Test
fun `given there is not enough options when the question is added then poll cannot be created and options can be added`() {
val createPollViewModel = createPollViewModel(PollMode.CREATE)
createPollViewModel.handle(CreatePollAction.OnQuestionChanged(fakeQuestion))
repeat(CreatePollViewModel.MIN_OPTIONS_COUNT - 1) {
createPollViewModel.handle(CreatePollAction.OnOptionChanged(it, fakeOptions[it]))
}
createPollViewModel
.test()
.assertState(pollViewStateWithQuestionAndNotEnoughOptions)
.finish()
}
}