Add Konsist check to ensure that '@PreviewLightDark' is not used.

This commit is contained in:
Benoit Marty 2024-04-18 14:08:18 +02:00
parent c98cb56b74
commit 4fe7b601af

View file

@ -16,8 +16,10 @@
package io.element.android.tests.konsist
import androidx.compose.ui.tooling.preview.PreviewLightDark
import com.lemonappdev.konsist.api.Konsist
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
import com.lemonappdev.konsist.api.verify.assertEmpty
import com.lemonappdev.konsist.api.verify.assertTrue
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import org.junit.Test
@ -57,4 +59,15 @@ class KonsistPreviewTest {
it.hasInternalModifier
}
}
@Test
fun `Ensure that '@PreviewLightDark' is not used`() {
Konsist
.scopeFromProject()
.functions()
.withAllAnnotationsOf(PreviewLightDark::class)
.assertEmpty(
additionalMessage = "Use '@PreviewsDayNight' instead of '@PreviewLightDark', or else screenshot(s) will not be generated.",
)
}
}