mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Test previews with a11y details and add a first example with HomeViewA11yPreview.
This commit is contained in:
committed by
Benoit Marty
parent
a625c109b8
commit
1d7e7e19d9
@@ -12,6 +12,7 @@ import com.google.common.truth.Truth.assertThat
|
||||
import com.lemonappdev.konsist.api.Konsist
|
||||
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
|
||||
import com.lemonappdev.konsist.api.ext.list.withName
|
||||
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
|
||||
import com.lemonappdev.konsist.api.ext.list.withoutName
|
||||
import com.lemonappdev.konsist.api.verify.assertEmpty
|
||||
import com.lemonappdev.konsist.api.verify.assertTrue
|
||||
@@ -32,6 +33,26 @@ class KonsistPreviewTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Check functions with 'A11yPreview'`() {
|
||||
Konsist
|
||||
.scopeFromProject()
|
||||
.functions()
|
||||
.withNameEndingWith("A11yPreview")
|
||||
.assertTrue(
|
||||
additionalMessage = "Functions with 'A11yPreview' suffix should have '@Previews' annotation and not '@PreviewsDayNight'," +
|
||||
" should contain 'ElementPreview' composable," +
|
||||
" should contain the tested view" +
|
||||
" and should be internal"
|
||||
) {
|
||||
val testedView = it.name.removeSuffix("A11yPreview")
|
||||
it.text.contains("$testedView(") &&
|
||||
it.hasAllAnnotationsOf(PreviewsDayNight::class).not() &&
|
||||
it.text.contains("ElementPreview") &&
|
||||
it.hasInternalModifier
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Functions with '@PreviewsDayNight' annotation should contain 'ElementPreview' composable`() {
|
||||
Konsist
|
||||
|
||||
Reference in New Issue
Block a user