Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
fix: call removeAllViews before addView (#905)
Browse files Browse the repository at this point in the history
Co-authored-by: Túlio Magalhães <[email protected]>
  • Loading branch information
tuliopereirazup and tuliomagalhaes authored Sep 14, 2020
1 parent a889d0b commit 3250594
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ private fun loadView(
loadView(screenRequest)
}
view.loadCompletedListener = {
viewGroup.removeAllViews()
viewGroup.addView(view)

}
view.listenerOnViewDetachedFromWindow = {
viewModel.setViewCreated(rootView.getParentId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,9 @@ import br.com.zup.beagle.android.view.custom.OnLoadCompleted
import br.com.zup.beagle.android.view.custom.OnStateChanged
import br.com.zup.beagle.android.view.viewmodel.GenerateIdViewModel
import br.com.zup.beagle.android.view.viewmodel.ScreenContextViewModel
import io.mockk.Runs
import io.mockk.every
import io.mockk.*
import io.mockk.impl.annotations.MockK
import io.mockk.impl.annotations.RelaxedMockK
import io.mockk.just
import io.mockk.mockkStatic
import io.mockk.slot
import io.mockk.verify
import io.mockk.verifySequence
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down Expand Up @@ -140,7 +134,7 @@ class ViewExtensionsKtTest : BaseTest() {
}

@Test
fun `loadView should addView when load complete`() {
fun `loadView should removeAllViews and addView when load complete`() {
// Given
val slot = slot<OnLoadCompleted>()
every { beagleView.loadCompletedListener = capture(slot) } just Runs
Expand All @@ -151,7 +145,10 @@ class ViewExtensionsKtTest : BaseTest() {

// Then
assertEquals(beagleView, viewSlot.captured)
verify(exactly = once()) { viewGroup.addView(beagleView) }
verifyOrder {
viewGroup.removeAllViews()
viewGroup.addView(beagleView)
}
}


Expand Down

0 comments on commit 3250594

Please sign in to comment.