Test previews with a11y details and add a first example with HomeViewA11yPreview.
This commit is contained in:
parent
4653164572
commit
c13d9a935b
5 changed files with 105 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue