@@ -15,6 +15,7 @@ import org.wordpress.android.R.string
1515import org.wordpress.android.util.LocaleManagerWrapper
1616import org.wordpress.android.util.text.PercentFormatter
1717import org.wordpress.android.viewmodel.ResourceProvider
18+ import java.math.RoundingMode.HALF_UP
1819import 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