ivano
01/16/2020, 9:30 AM@Test
fun `when I add an image OCR Alert shows the date`() {
formType = DeclarationFormType.RECEIPT
formState = FormState.CREATE
val ocrProcessor = mock<FirebaseFormProcessor>()
viewModel = DeclarationViewModel(null, formType, formState, mock(), Application(), ocrProcessor)
//when i add image
val bitmap = mock<Bitmap>()
val dateTextExtraction = mock<DateTextExtraction>()
whenever(dateTextExtraction.newValue).thenReturn("A value")
// expected
val date = listOf(DateTextExtraction())
val callback = mockk<(List<TextExtractionInterface>) -> Unit>()
viewModel.addImage(bitmap)
every { ocrProcessor.scan(bitmap, date, callback) } answers {
callback(date)
}
//then shows Alert with Date
viewModel.ocrAlert
.test()
.assertValue {
it == date
}
.addTo(disposeBag)
}