mirror of
https://github.com/hmalik144/Farmr.git
synced 2026-03-18 15:35:55 +00:00
- Local unit tests added
- Optomized imports
This commit is contained in:
@@ -10,7 +10,6 @@ import io.mockk.mockk
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers.anyLong
|
||||
import java.util.UUID
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertIs
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@ package com.appttude.h_mal.farmr.utils
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import com.appttude.h_mal.farmr.data.legacydb.ShiftObject
|
||||
import com.appttude.h_mal.farmr.model.ShiftType
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.mockito.ArgumentMatchers
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
@@ -36,4 +39,111 @@ fun <T> LiveData<T>.getOrAwaitValue(
|
||||
|
||||
fun sleep(millis: Long = 1000) {
|
||||
runBlocking(Dispatchers.Default) { delay(millis) }
|
||||
}
|
||||
}
|
||||
|
||||
fun getShifts() = listOf(
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day one",
|
||||
"2023-08-01",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
ArgumentMatchers.anyInt(),
|
||||
ArgumentMatchers.anyFloat(),
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day two",
|
||||
"2023-08-02",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
ArgumentMatchers.anyInt(),
|
||||
ArgumentMatchers.anyFloat(),
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day three",
|
||||
"2023-08-03",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
30,
|
||||
ArgumentMatchers.anyFloat(),
|
||||
10f,
|
||||
5f
|
||||
),
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day four",
|
||||
"2023-08-04",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
30,
|
||||
ArgumentMatchers.anyFloat(),
|
||||
10f,
|
||||
5f
|
||||
),
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day five",
|
||||
"2023-08-05",
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyFloat(),
|
||||
ArgumentMatchers.anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day six",
|
||||
"2023-08-06",
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyFloat(),
|
||||
ArgumentMatchers.anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day seven",
|
||||
"2023-08-07",
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyFloat(),
|
||||
ArgumentMatchers.anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
ArgumentMatchers.anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day eight",
|
||||
"2023-08-08",
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyFloat(),
|
||||
ArgumentMatchers.anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
)
|
||||
@@ -10,17 +10,14 @@ import com.appttude.h_mal.farmr.data.prefs.TYPE
|
||||
import com.appttude.h_mal.farmr.model.ShiftType
|
||||
import com.appttude.h_mal.farmr.model.ViewState
|
||||
import com.appttude.h_mal.farmr.utils.getOrAwaitValue
|
||||
import com.appttude.h_mal.farmr.utils.getShifts
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers.anyFloat
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.ArgumentMatchers.anyList
|
||||
import org.mockito.ArgumentMatchers.anyLong
|
||||
import org.mockito.ArgumentMatchers.anyString
|
||||
import java.util.concurrent.TimeoutException
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -130,110 +127,4 @@ class MainViewModelTest {
|
||||
Pair(TYPE, type)
|
||||
)
|
||||
|
||||
private fun getShifts() = listOf(
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day one",
|
||||
"2023-08-01",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
anyInt(),
|
||||
anyFloat(),
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day two",
|
||||
"2023-08-02",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
anyInt(),
|
||||
anyFloat(),
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day three",
|
||||
"2023-08-03",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
30,
|
||||
anyFloat(),
|
||||
10f,
|
||||
5f
|
||||
),
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.HOURLY.type,
|
||||
"Day four",
|
||||
"2023-08-04",
|
||||
"12:00",
|
||||
"13:00",
|
||||
1f,
|
||||
30,
|
||||
anyFloat(),
|
||||
10f,
|
||||
5f
|
||||
),
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day five",
|
||||
"2023-08-05",
|
||||
anyString(),
|
||||
anyString(),
|
||||
anyFloat(),
|
||||
anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day six",
|
||||
"2023-08-06",
|
||||
anyString(),
|
||||
anyString(),
|
||||
anyFloat(),
|
||||
anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day seven",
|
||||
"2023-08-07",
|
||||
anyString(),
|
||||
anyString(),
|
||||
anyFloat(),
|
||||
anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
ShiftObject(
|
||||
anyLong(),
|
||||
ShiftType.PIECE.type,
|
||||
"Day eight",
|
||||
"2023-08-08",
|
||||
anyString(),
|
||||
anyString(),
|
||||
anyFloat(),
|
||||
anyInt(),
|
||||
1f,
|
||||
10f,
|
||||
10f
|
||||
),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user