Skip to content

Commit

Permalink
Add konsist test to ensure we do not use uiState variable name or col…
Browse files Browse the repository at this point in the history
…lectAsState
  • Loading branch information
Rawa committed Mar 5, 2024
1 parent 12a0137 commit 2691360
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
}

0 comments on commit 2691360

Please sign in to comment.