Skip to content

Commit 82902ed

Browse files
Add more unit tests
1 parent 8311417 commit 82902ed

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/details/ProductDetailViewModelTest.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,32 @@ class ProductDetailViewModelTest : BaseUnitTest() {
14041404
Assertions.assertThat(menuButtonsState.viewProductOption).isFalse()
14051405
}
14061406

1407+
@Test
1408+
fun `given we can authenticate the user in WebView, when tapping on view product, then show authenticated webview`() =
1409+
testBlocking {
1410+
given(canAutoAuthenticateInWebView.invoke(any())).willReturn(true)
1411+
given(productRepository.getProductAggregate(any())).willReturn(productAggregate)
1412+
1413+
viewModel.start()
1414+
viewModel.onViewProductOnStoreLinkClicked()
1415+
1416+
Assertions.assertThat(viewModel.event.value)
1417+
.isEqualTo(MultiLiveEvent.Event.LaunchUrlInAuthenticatedWebView(productAggregate.product.permalink))
1418+
}
1419+
1420+
@Test
1421+
fun `given we can't authenticate the user in WebView, when tapping on view product, then show Chrome Custom Tab`() =
1422+
testBlocking {
1423+
given(canAutoAuthenticateInWebView.invoke(any())).willReturn(false)
1424+
given(productRepository.getProductAggregate(any())).willReturn(productAggregate)
1425+
1426+
viewModel.start()
1427+
viewModel.onViewProductOnStoreLinkClicked()
1428+
1429+
Assertions.assertThat(viewModel.event.value)
1430+
.isEqualTo(MultiLiveEvent.Event.LaunchUrlInChromeTab(productAggregate.product.permalink))
1431+
}
1432+
14071433
private val productsDraft
14081434
get() = viewModel.productDetailViewStateData.liveData.value?.productDraft
14091435
}

0 commit comments

Comments
 (0)