@RunWith(MockitoJUnitRunner::class)
class MoreHomeFragmentTest {
private lateinit var perfilFragment:MoreHomeFragment
@Mock
private lateinit var activity:MainActivity
@Mock
lateinit var activityComponent: ActivityComponent
@Mock
lateinit var presenter: MoreHomePresenter
@Mock
private lateinit var adapter: MenuAdapter
@Mock
lateinit var context:Context
@Before
fun setUp() {
activity = MainActivity()
perfilFragment = MoreHomeFragment()
startFragment(perfilFragment)
perfilFragment.activityComponent = activityComponent
perfilFragment.presenter = presenter
}
@Test
fun deve_Atualizar_Lista_Menus(){
adapter = MenuAdapter(context)
perfilFragment.onActivityCreated(null)
perfilFragment.configureMenu(false)
val menuItems = ArrayList<MenuItem>()
verify(adapter).setDataList(menuItems)
}
private fun startFragment(perfilFragment: Fragment) {
val fragmentManager = activity.supportFragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.container, perfilFragment)
fragmentTransaction.commit()
}
}