summaryrefslogtreecommitdiffhomepage
path: root/android/test
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson90@gmail.com>2024-03-05 11:08:39 +0100
committerAlbin <albin@mullvad.net>2024-03-05 12:42:22 +0100
commitfb2f74a7c7a7c233762491800bc6cbbd66ce85e4 (patch)
tree97d67661e0bd20b00fd457356a1dfb5a90faa4f3 /android/test
parent2480eebbdac8a7990f79b366f25a44a594cdd7a7 (diff)
downloadmullvadvpn-fb2f74a7c7a7c233762491800bc6cbbd66ce85e4.tar.xz
mullvadvpn-fb2f74a7c7a7c233762491800bc6cbbd66ce85e4.zip
Add konsist test to ensure we do not use uiState variable name or collectAsState
Diffstat (limited to 'android/test')
-rw-r--r--android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTest.kt11
1 files changed, 11 insertions, 0 deletions
diff --git a/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTest.kt b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTest.kt
index fc84d3d0aa..15c581c23b 100644
--- a/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTest.kt
+++ b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTest.kt
@@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.test.arch.compose
import androidx.compose.runtime.Composable
import com.lemonappdev.konsist.api.Konsist
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
+import com.lemonappdev.konsist.api.verify.assertFalse
import com.lemonappdev.konsist.api.verify.assertTrue
import org.junit.jupiter.api.Test
@@ -13,6 +14,16 @@ class ComposeTest {
it.resideInPackage("net.mullvad.mullvadvpn.compose..")
}
+ @Test
+ fun `ensure we don't use collectAsState`() =
+ Konsist.scopeFromProduction("app").imports.assertFalse {
+ it.name == "androidx.compose.runtime.collectAsState"
+ }
+
+ @Test
+ fun `ensure all composables do not refer to state as uiState`() =
+ allAppComposeFunctions().assertFalse { it.hasParameter { it.name == "uiState" } }
+
private fun allAppComposeFunctions() =
Konsist.scopeFromProduction("app").functions().withAllAnnotationsOf(Composable::class)
}