This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Missing tracing duration on low risk detail screen (EXPOSUREAPP-5092) (…
…#2326) * Show active tracing history in low risk detail screen * Move isGone logic from xml layout into state object and add tests Co-authored-by: Ralf Gehrer <ralfgehrer@users.noreply.github.com> Co-authored-by: harambasicluka <64483219+harambasicluka@users.noreply.github.com>
- Loading branch information
1 parent
a7333d8
commit 8eefd38
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Corona-Warn-App/src/test/java/de/rki/coronawarnapp/tracing/states/LowRiskTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package de.rki.coronawarnapp.tracing.states | ||
|
||
import android.content.Context | ||
import de.rki.coronawarnapp.R | ||
import de.rki.coronawarnapp.risk.RiskState | ||
import io.kotest.matchers.shouldBe | ||
import io.mockk.MockKAnnotations | ||
import io.mockk.clearAllMocks | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.MockK | ||
import org.joda.time.Instant | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
|
||
internal class LowRiskTest { | ||
|
||
@MockK private lateinit var context: Context | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
MockKAnnotations.init(this) | ||
every { | ||
context.getString( | ||
R.string.risk_card_low_risk_most_recent_body_encounter_on_single_day, | ||
any() | ||
) | ||
} returns "String not relevant for this test" | ||
} | ||
|
||
@AfterEach | ||
fun tearDown() { | ||
clearAllMocks() | ||
} | ||
|
||
private val defaultRisk = LowRisk( | ||
riskState = RiskState.LOW_RISK, | ||
isInDetailsMode = false, | ||
lastExposureDetectionTime = Instant.now(), | ||
allowManualUpdate = false, | ||
daysWithEncounters = 0, | ||
activeTracingDays = 1, | ||
lastEncounterAt = null | ||
) | ||
|
||
@Test | ||
fun `Active tracing row should be visible in low risk card on the home screen when there are no encounters`() { | ||
defaultRisk.isGoneOnContentLowView(context) shouldBe false | ||
} | ||
|
||
@Test | ||
fun `Active tracing row should be gone in low risk card on the home screen when there are encounters`() { | ||
defaultRisk | ||
.copy(daysWithEncounters = 1, lastEncounterAt = Instant.now()) | ||
.isGoneOnContentLowView(context) shouldBe true | ||
} | ||
|
||
@Test | ||
fun `Active tracing row should be shown in low risk detail screen when there are no encounters`() { | ||
defaultRisk | ||
.copy(isInDetailsMode = true) | ||
.isGoneOnContentLowView(context) shouldBe false | ||
} | ||
|
||
@Test | ||
fun `Active tracing row should be shown in low risk detail screen when there are encounters`() { | ||
defaultRisk | ||
.copy(daysWithEncounters = 1, lastEncounterAt = Instant.now(), isInDetailsMode = true) | ||
.isGoneOnContentLowView(context) shouldBe false | ||
} | ||
} |