Abhinav Sharma
11/19/2021, 9:13 AMHorizontalTrayUi()
and TrayItemUi()
Its easy to test TrayItemUi()
in isolation by mocking TrayItemViewModel
and its exposed state flows, but whats the recommended way to test HorizontalTrayUi()
as it calls TrayItemUi()
which then tries to create a viewModel using Hilt
Here’s the structure
@Composable
fun HorizontalTrayUi(
trayModel: TrayModle,
viewModel: TrayViewModel = viewModel()
) {
Text(...) // title of the tray
LazyRow(..){
item -> {
TrayItemUi(item)
}
}
}
@Composable
fun TrayItemUi(
item: TrayItemModel,
viewModel: TrayItemViewModel = viewModel()
) {
......
}
@Pedro GomezPedro Gomez
11/19/2021, 10:01 AMAbhinav Sharma
11/19/2021, 10:25 AMPedro Gomez
11/22/2021, 11:57 PM