Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit f6b7810

Browse files
committed
Add test for fetching products with the global unique id
1 parent f1529b3 commit f6b7810

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

plugins/woocommerce/src/test/java/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductRestClientTest.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,33 @@ class ProductRestClientTest {
162162
}
163163
}
164164

165+
@Test
166+
fun `when fetch products called with the global unique id, then correct params is used for network call`() {
167+
runBlockingTest {
168+
val globalUniqueIdSearchQuery = "test global unique id"
169+
sut.fetchProducts(
170+
site = site,
171+
globalUniqueIdSearchQuery = globalUniqueIdSearchQuery
172+
)
173+
val argumentCaptor = argumentCaptor<MutableMap<String, String>>()
174+
verify(wooNetwork).executeGetGsonRequest(
175+
any(),
176+
any(),
177+
clazz = eq(Array<ProductApiResponse>::class.java),
178+
params = argumentCaptor.capture(),
179+
enableCaching = any(),
180+
cacheTimeToLive = any(),
181+
forced = any(),
182+
requestTimeout = any(),
183+
retries = any()
184+
)
185+
186+
assertThat(argumentCaptor.firstValue.getOrDefault("global_unique_id", null)).isEqualTo(
187+
globalUniqueIdSearchQuery
188+
)
189+
}
190+
}
191+
165192
private fun WCProductModel.withRegularPrice(newRegularPrice: String): WCProductModel =
166193
copy().apply {
167194
remoteProductId = this@withRegularPrice.remoteProductId

0 commit comments

Comments
 (0)