Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Jan 31, 2024
1 parent 2aca539 commit 80a23eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import java.util.Calendar
import java.util.Date
import javax.inject.Inject
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
Expand Down Expand Up @@ -360,6 +361,22 @@ internal class HivRegisterDaoTest : RobolectricTest() {
assertEquals(HealthStatus.EXPOSED_INFANT, hivProfileData.healthStatus)
assertEquals(Enumerations.AdministrativeGender.MALE, hivProfileData.gender)
}
@Test
fun testProfileTaskList() {
val data = runBlocking {
hivRegisterDao.loadProfileData(appFeatureName = "HIV", resourceId = "1")
}
assertNotNull(data)
val hivProfileData = data as ProfileData.HivProfileData
val order = hivProfileData.tasks.none { it.clinicVisitOrder("https://d-tree.org") == null }
Assert.assertEquals(hivProfileData.tasks.isEmpty(), false)
val sorted = hivProfileData.tasks.sortedWith(compareBy { it.description }).isEmpty()
val sortedIds = hivProfileData.tasks.map { it.id }

assertFalse(sorted)
assertEquals(order, true)
assertEquals(listOf("2", "1"), sortedIds)
}

@Test
fun `loadGuardiansRegisterData returns from relatedPersons`() = runTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ class QuestionnaireViewModelTest : RobolectricTest() {

@Test
fun `test generateQuestionnaireResponse`() = runTest {
val questionnaire = Questionnaire()
val questionnaire = Questionnaire().apply { id = "test" }
val patient = samplePatient()
coEvery {
questionnaireViewModel.getPopulationResources(any(), questionnaire.logicalId)
Expand All @@ -1263,6 +1263,7 @@ class QuestionnaireViewModelTest : RobolectricTest() {
val response = questionnaireViewModel.generateQuestionnaireResponse(questionnaire, intent)

Assert.assertNotNull(response.contained.firstOrNull { it.resourceType == ResourceType.Patient })
Assert.assertEquals(response.questionnaire, "${questionnaire.resourceType}/test")
}

@Test
Expand Down

0 comments on commit 80a23eb

Please sign in to comment.