Skip to content

Commit

Permalink
WIP: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed May 3, 2024
1 parent 1d13b04 commit 9fffc7a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/androidTest/java/com/infomaniak/lib/core/ExtensionsTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.infomaniak.lib.core

import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.infomaniak.lib.core.utils.humanReadableBinaryBytesCount
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.mock
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations

/**
* Extensions file test
*/
@RunWith(AndroidJUnit4::class)
class ExtensionsTest {

@Mock
lateinit var mockContext: Context

@Before
fun setup() {
MockitoAnnotations.initMocks(this)
mockContext = mock(Context::class.java)
`when`(mockContext.applicationContext).thenReturn(mockContext)
}

@Test
fun humanReadableBinaryBytesCount() {
// Arrange (already in setup)

// Act
val result = mockContext.humanReadableBinaryBytesCount(1_500L)

// Assert
Assert.assertEquals(result, "1.5 KB")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.mockito.MockitoAnnotations
*/
@RunWith(AndroidJUnit4::class)
class HttpUtilsTest {

@Mock
lateinit var mockContext: Context

Expand Down Expand Up @@ -63,7 +64,7 @@ class HttpUtilsTest {

@Test
fun getHeaders_Test() {
// Arrange (Already in setup)
// Arrange (already in setup)

// Act
val headers: Headers = HttpUtils.getHeaders()
Expand Down

0 comments on commit 9fffc7a

Please sign in to comment.