Skip to content

Commit 19bd270

Browse files
committed
Fix failing StatsUtilsTest test
1 parent 00d73dc commit 19bd270

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils

WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/StatsUtilsTest.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.wordpress.android.R.string
1515
import org.wordpress.android.util.LocaleManagerWrapper
1616
import org.wordpress.android.util.text.PercentFormatter
1717
import org.wordpress.android.viewmodel.ResourceProvider
18+
import java.math.RoundingMode.HALF_UP
1819
import java.util.Locale
1920

2021
@RunWith(MockitoJUnitRunner::class)
@@ -258,7 +259,7 @@ class StatsUtilsTest {
258259

259260
@Test
260261
fun `build change with positive difference`() {
261-
whenever(percentFormatter.format(3.0F)).thenReturn("300")
262+
whenever(percentFormatter.format(value = 3.0F, rounding = HALF_UP)).thenReturn("300")
262263
val previousValue = 5L
263264
val value = 20L
264265
val positive = true
@@ -273,7 +274,7 @@ class StatsUtilsTest {
273274

274275
@Test
275276
fun `build change with infinite positive difference`() {
276-
whenever(percentFormatter.format(3.0F)).thenReturn("")
277+
whenever(percentFormatter.format(value = 3.0F, rounding = HALF_UP)).thenReturn("")
277278
val previousValue = 0L
278279
val value = 20L
279280
val positive = true
@@ -288,7 +289,7 @@ class StatsUtilsTest {
288289

289290
@Test
290291
fun `build change with negative difference`() {
291-
whenever(percentFormatter.format(-0.33333334F)).thenReturn("-33")
292+
whenever(percentFormatter.format(value = -0.33333334F, rounding = HALF_UP)).thenReturn("-33")
292293
val previousValue = 30L
293294
val value = 20L
294295
val positive = false
@@ -304,7 +305,7 @@ class StatsUtilsTest {
304305
@Test
305306
fun `build change with max negative difference`() {
306307
val previousValue = 20L
307-
whenever(percentFormatter.format(-1F)).thenReturn("-100")
308+
whenever(percentFormatter.format(value = -1F, rounding = HALF_UP)).thenReturn("-100")
308309
val value = 0L
309310
val positive = false
310311
val expectedChange = "-20 (-100%)"
@@ -332,8 +333,8 @@ class StatsUtilsTest {
332333

333334
@Test
334335
fun `when buildChange, should call PercentFormatter`() {
335-
whenever(percentFormatter.format(3.0F)).thenReturn("3%")
336+
whenever(percentFormatter.format(value = 3.0F, rounding = HALF_UP)).thenReturn("3%")
336337
statsUtils.buildChange(5L, 20L, true, isFormattedNumber = true)
337-
verify(percentFormatter).format(3.0F)
338+
verify(percentFormatter).format(value = 3.0F, rounding = HALF_UP)
338339
}
339340
}

0 commit comments

Comments
 (0)