Skip to content

Commit

Permalink
Merge pull request #292 from wealthfront/sample-tweaks
Browse files Browse the repository at this point in the history
Sample app: Use verify instead of coverify to prevent confusion
  • Loading branch information
cmathew committed Oct 27, 2023
2 parents a987f4e + 6041091 commit b4b1e43
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Expand Up @@ -8,11 +8,10 @@ import androidx.recyclerview.widget.RecyclerView
import com.wealthfront.magellan.sample.migration.R

class DogListAdapter(
var dataSet: List<String> = emptyList(),
private val onDogSelected: (String) -> Unit
) : RecyclerView.Adapter<DogListAdapter.ViewHolder>() {

var dataSet: Array<String> = emptyArray()

class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {

val textView: TextView = view.findViewById(R.id.dogName)
Expand Down
Expand Up @@ -30,15 +30,15 @@ class DogListStep @AssistedInject constructor(
override fun onShow(context: Context, binding: DashboardBinding) {
toolbarHelper.setTitle(context.getText(R.string.app_name))
binding.dogItems.layoutManager = LinearLayoutManager(context, VERTICAL, false)
binding.dogItems.adapter = DogListAdapter(goToDogDetails)
binding.dogItems.adapter = DogListAdapter(emptyList(), goToDogDetails)
val decoration = DividerItemDecoration(context, VERTICAL)
binding.dogItems.addItemDecoration(decoration)

binding.dogItemsLoading.visibility = View.VISIBLE
shownScope.launch {
val dogBreedsResponse = runCatching { api.getAllBreeds() }
dogBreedsResponse.onSuccess { dogBreeds ->
(binding.dogItems.adapter as DogListAdapter).dataSet = dogBreeds.message.keys.toTypedArray()
(binding.dogItems.adapter as DogListAdapter).dataSet = dogBreeds.message.keys.toList()
(binding.dogItems.adapter as DogListAdapter).notifyDataSetChanged()
}
dogBreedsResponse.onFailure { throwable ->
Expand Down
Expand Up @@ -11,8 +11,8 @@ import com.wealthfront.magellan.sample.migration.AppComponentContainer
import com.wealthfront.magellan.sample.migration.TestAppComponent
import com.wealthfront.magellan.sample.migration.api.DogImageResponse
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.mockk
import io.mockk.verify
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -55,6 +55,6 @@ class DogDetailsScreenTest {
fun fetchesDogBreedOnShow() {
screen.transitionToState(LifecycleState.Shown(activity))
shadowOf(getMainLooper()).idle()
coVerify { dogDetailsView.setDogPic("image-url") }
verify { dogDetailsView.setDogPic("image-url") }
}
}

0 comments on commit b4b1e43

Please sign in to comment.