Skip to content

Commit

Permalink
Add more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamboushaba committed Feb 7, 2025
1 parent 8311417 commit 82902ed
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,32 @@ class ProductDetailViewModelTest : BaseUnitTest() {
Assertions.assertThat(menuButtonsState.viewProductOption).isFalse()
}

@Test
fun `given we can authenticate the user in WebView, when tapping on view product, then show authenticated webview`() =
testBlocking {
given(canAutoAuthenticateInWebView.invoke(any())).willReturn(true)
given(productRepository.getProductAggregate(any())).willReturn(productAggregate)

viewModel.start()
viewModel.onViewProductOnStoreLinkClicked()

Assertions.assertThat(viewModel.event.value)
.isEqualTo(MultiLiveEvent.Event.LaunchUrlInAuthenticatedWebView(productAggregate.product.permalink))
}

@Test
fun `given we can't authenticate the user in WebView, when tapping on view product, then show Chrome Custom Tab`() =
testBlocking {
given(canAutoAuthenticateInWebView.invoke(any())).willReturn(false)
given(productRepository.getProductAggregate(any())).willReturn(productAggregate)

viewModel.start()
viewModel.onViewProductOnStoreLinkClicked()

Assertions.assertThat(viewModel.event.value)
.isEqualTo(MultiLiveEvent.Event.LaunchUrlInChromeTab(productAggregate.product.permalink))
}

private val productsDraft
get() = viewModel.productDetailViewStateData.liveData.value?.productDraft
}

0 comments on commit 82902ed

Please sign in to comment.