Improve Konsist test.
This commit is contained in:
parent
ea94ec32b4
commit
5541ca7427
1 changed files with 105 additions and 84 deletions
|
|
@ -8,8 +8,10 @@
|
|||
package io.element.android.tests.konsist
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||
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.withoutName
|
||||
import com.lemonappdev.konsist.api.verify.assertEmpty
|
||||
import com.lemonappdev.konsist.api.verify.assertTrue
|
||||
|
|
@ -52,13 +54,7 @@ class KonsistPreviewTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Functions with '@PreviewsDayNight' have correct name`() {
|
||||
Konsist
|
||||
.scopeFromProject()
|
||||
.functions()
|
||||
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||
.withoutName(
|
||||
private val previewNameExceptions = listOf(
|
||||
"AsyncIndicatorFailurePreview",
|
||||
"AsyncIndicatorLoadingPreview",
|
||||
"BackgroundVerticalGradientDisabledPreview",
|
||||
|
|
@ -73,16 +69,14 @@ class KonsistPreviewTest {
|
|||
"IconsCompoundPreview",
|
||||
"IconsOtherPreview",
|
||||
"MarkdownTextComposerEditPreview",
|
||||
"MatrixBadgeAtomPositivePreview",
|
||||
"MatrixBadgeAtomNeutralPreview",
|
||||
"MatrixBadgeAtomNegativePreview",
|
||||
"MatrixBadgeAtomInfoPreview",
|
||||
"MentionSpanPreview",
|
||||
"MatrixBadgeAtomNegativePreview",
|
||||
"MatrixBadgeAtomNeutralPreview",
|
||||
"MatrixBadgeAtomPositivePreview",
|
||||
"MessageComposerViewVoicePreview",
|
||||
"MessagesReactionButtonAddPreview",
|
||||
"MessagesReactionButtonExtraPreview",
|
||||
"MessagesViewWithIdentityChangePreview",
|
||||
"MessagesViewWithTypingPreview",
|
||||
"PageTitleWithIconFullPreview",
|
||||
"PageTitleWithIconMinimalPreview",
|
||||
"PendingMemberRowWithLongNamePreview",
|
||||
|
|
@ -107,21 +101,19 @@ class KonsistPreviewTest {
|
|||
"SelectedUserCannotRemovePreview",
|
||||
"TextComposerAddCaptionPreview",
|
||||
"TextComposerCaptionPreview",
|
||||
"TextComposerEditPreview",
|
||||
"TextComposerEditNotEncryptedPreview",
|
||||
"TextComposerEditCaptionPreview",
|
||||
"TextComposerFormattingPreview",
|
||||
"TextComposerEditNotEncryptedPreview",
|
||||
"TextComposerEditPreview",
|
||||
"TextComposerFormattingNotEncryptedPreview",
|
||||
"TextComposerFormattingPreview",
|
||||
"TextComposerLinkDialogCreateLinkPreview",
|
||||
"TextComposerLinkDialogCreateLinkWithoutTextPreview",
|
||||
"TextComposerLinkDialogEditLinkPreview",
|
||||
"TextComposerReplyPreview",
|
||||
"TextComposerReplyNotEncryptedPreview",
|
||||
"TextComposerSimplePreview",
|
||||
"TextComposerSimpleNotEncryptedPreview",
|
||||
"TextComposerVoicePreview",
|
||||
"TextComposerSimplePreview",
|
||||
"TextComposerVoiceNotEncryptedPreview",
|
||||
"TextFieldDialogWithBorderPreview",
|
||||
"TextComposerVoicePreview",
|
||||
"TextFieldDialogWithErrorPreview",
|
||||
"TimelineImageWithCaptionRowPreview",
|
||||
"TimelineItemEventRowForDirectRoomPreview",
|
||||
|
|
@ -142,6 +134,35 @@ class KonsistPreviewTest {
|
|||
"UserProfileHeaderSectionWithVerificationViolationPreview",
|
||||
"VoiceItemViewPlayPreview",
|
||||
)
|
||||
|
||||
@Test
|
||||
fun `previewNameExceptions is sorted alphabetically`() {
|
||||
assertThat(previewNameExceptions.sorted()).isEqualTo(previewNameExceptions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `previewNameExceptions only contains existing functions`() {
|
||||
val names = previewNameExceptions.toMutableSet()
|
||||
Konsist
|
||||
.scopeFromProject()
|
||||
.functions()
|
||||
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||
.withName(previewNameExceptions)
|
||||
.let {
|
||||
it.forEach { function ->
|
||||
names.remove(function.name)
|
||||
}
|
||||
}
|
||||
assertThat(names).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Functions with '@PreviewsDayNight' have correct name`() {
|
||||
Konsist
|
||||
.scopeFromProject()
|
||||
.functions()
|
||||
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||
.withoutName(previewNameExceptions)
|
||||
.assertTrue(
|
||||
additionalMessage = "Functions for Preview should be named like this: <ViewUnderPreview>Preview. " +
|
||||
"Exception can be added to the test, for multiple Previews of the same view",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue