Skip to content
Snippets Groups Projects
Unverified Commit 67fd528d authored by Matthias Urhahn's avatar Matthias Urhahn Committed by GitHub
Browse files

Add valueset storage tests (DEV) (#3298)

* Add tests for valueset storage format.

* Remove extra case and add check for reloading.
parent d08a6a37
No related branches found
No related tags found
No related merge requests found
......@@ -10,12 +10,14 @@ import de.rki.coronawarnapp.vaccination.core.ValueSetTestData.valueSetDe
import de.rki.coronawarnapp.vaccination.core.ValueSetTestData.valueSetEn
import de.rki.coronawarnapp.vaccination.core.validateValues
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import testhelpers.BaseTest
import testhelpers.extensions.toComparableJsonPretty
import testhelpers.preferences.MockSharedPreferences
class ValueSetsStorageTest : BaseTest() {
......@@ -76,4 +78,65 @@ class ValueSetsStorageTest : BaseTest() {
}
}
}
@Test
fun `storage inits empty without sideeffects`() {
createInstance().vaccinationValueSet shouldNotBe null
prefs.dataMapPeek.isEmpty() shouldBe true
}
@Test
fun `storage format`() {
createInstance().vaccinationValueSet = storedValueSetDe
(prefs.dataMapPeek["valueset"] as String).toComparableJsonPretty() shouldBe """
{
"languageCode": "de",
"vp": {
"items": [
{
"key": "1119305005",
"displayText": "Impfstoff-Name"
}
]
},
"mp": {
"items": [
{
"key": "EU/1/21/1529",
"displayText": "Arzneimittel-Name"
}
]
},
"ma": {
"items": [
{
"key": "ORG-100001699",
"displayText": "Hersteller-Name"
}
]
}
}
""".toComparableJsonPretty()
createInstance().apply {
vaccinationValueSet shouldBe storedValueSetDe
vaccinationValueSet = emptyStoredValueSet
}
(prefs.dataMapPeek["valueset"] as String).toComparableJsonPretty() shouldBe """
{
"languageCode": "en",
"vp": {
"items": []
},
"mp": {
"items": []
},
"ma": {
"items": []
}
}
""".toComparableJsonPretty()
createInstance().vaccinationValueSet shouldBe emptyStoredValueSet
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment