Skip to content

Commit 2691360

Browse files
committed
Add konsist test to ensure we do not use uiState variable name or collectAsState
1 parent 12a0137 commit 2691360

File tree

1 file changed

+11
-0
lines changed
  • android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose

1 file changed

+11
-0
lines changed

android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTest.kt

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.test.arch.compose
33
import androidx.compose.runtime.Composable
44
import com.lemonappdev.konsist.api.Konsist
55
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
6+
import com.lemonappdev.konsist.api.verify.assertFalse
67
import com.lemonappdev.konsist.api.verify.assertTrue
78
import org.junit.jupiter.api.Test
89

@@ -13,6 +14,16 @@ class ComposeTest {
1314
it.resideInPackage("net.mullvad.mullvadvpn.compose..")
1415
}
1516

17+
@Test
18+
fun `ensure we don't use collectAsState`() =
19+
Konsist.scopeFromProduction("app").imports.assertFalse {
20+
it.name == "androidx.compose.runtime.collectAsState"
21+
}
22+
23+
@Test
24+
fun `ensure all composables do not refer to state as uiState`() =
25+
allAppComposeFunctions().assertFalse { it.hasParameter { it.name == "uiState" } }
26+
1627
private fun allAppComposeFunctions() =
1728
Konsist.scopeFromProduction("app").functions().withAllAnnotationsOf(Composable::class)
1829
}

0 commit comments

Comments
 (0)