Skip to content

Commit

Permalink
Add test for fetching products with the global unique id
Browse files Browse the repository at this point in the history
  • Loading branch information
toupper committed Dec 4, 2024
1 parent f1529b3 commit f6b7810
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,33 @@ class ProductRestClientTest {
}
}

@Test
fun `when fetch products called with the global unique id, then correct params is used for network call`() {
runBlockingTest {
val globalUniqueIdSearchQuery = "test global unique id"
sut.fetchProducts(
site = site,
globalUniqueIdSearchQuery = globalUniqueIdSearchQuery
)
val argumentCaptor = argumentCaptor<MutableMap<String, String>>()
verify(wooNetwork).executeGetGsonRequest(
any(),
any(),
clazz = eq(Array<ProductApiResponse>::class.java),
params = argumentCaptor.capture(),
enableCaching = any(),
cacheTimeToLive = any(),
forced = any(),
requestTimeout = any(),
retries = any()
)

assertThat(argumentCaptor.firstValue.getOrDefault("global_unique_id", null)).isEqualTo(
globalUniqueIdSearchQuery
)
}
}

private fun WCProductModel.withRegularPrice(newRegularPrice: String): WCProductModel =
copy().apply {
remoteProductId = this@withRegularPrice.remoteProductId
Expand Down

0 comments on commit f6b7810

Please sign in to comment.