Browse Source

Core with Frefox tests enabled (#1563)

pull/1562/head
Shagen Ogandzhanian 3 years ago committed by GitHub
parent
commit
90cb181a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      web/core/build.gradle.kts
  2. 58
      web/core/src/jsTest/kotlin/css/AnimationTests.kt

2
web/core/build.gradle.kts

@ -12,7 +12,7 @@ kotlin {
useKarma { useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d") useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless() useChromeHeadless()
//useFirefox() useFirefox()
} }
} }
} }

58
web/core/src/jsTest/kotlin/css/AnimationTests.kt

@ -8,12 +8,12 @@ import org.jetbrains.compose.web.ExperimentalComposeWebApi
import org.jetbrains.compose.web.testutils.* import org.jetbrains.compose.web.testutils.*
import org.jetbrains.compose.web.css.* import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.stringPresentation import org.jetbrains.compose.web.dom.stringPresentation
import org.w3c.dom.HTMLElement
import org.w3c.dom.HTMLStyleElement import org.w3c.dom.HTMLStyleElement
import org.w3c.dom.css.CSSStyleSheet import org.w3c.dom.css.CSSStyleSheet
import org.w3c.dom.get import org.w3c.dom.get
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertContains import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
object AnimationsStyleSheet : StyleSheet() { object AnimationsStyleSheet : StyleSheet() {
val bounce by keyframes { val bounce by keyframes {
@ -39,30 +39,15 @@ object AnimationsStyleSheet : StyleSheet() {
class AnimationTests { class AnimationTests {
@Test @Test
fun animationClassGenerated() = runTest { fun animationClassGenerated() = runTest {
val generatedRules = AnimationsStyleSheet.cssRules.map { it.stringPresentation() } val generatedRules = AnimationsStyleSheet.cssRules.map { it.stringPresentation(indent = " ", delimiter = "") }
assertContains(
generatedRules, assertContentEquals(
""" listOf(
@keyframes AnimationsStyleSheet-bounce { "@keyframes AnimationsStyleSheet-bounce { from { transform: translateX(50%); } to { transform: translateX(-50%); }}",
from { ".AnimationsStyleSheet-animationClass { animation: AnimationsStyleSheet-bounce 2s ease-in alternate;}"
transform: translateX(50%); ),
} generatedRules
to {
transform: translateX(-50%);
}
}
""".trimIndent(),
"Animation keyframes wasn't generated correctly"
)
assertContains(
generatedRules,
"""
.AnimationsStyleSheet-animationClass {
animation: AnimationsStyleSheet-bounce 2s ease-in alternate;
}
""".trimIndent(),
"Animation class wasn't generated correctly"
) )
} }
@ -75,24 +60,19 @@ class AnimationTests {
val el = root.children[0] as HTMLStyleElement val el = root.children[0] as HTMLStyleElement
val cssRules = (el.sheet as? CSSStyleSheet)?.cssRules val cssRules = (el.sheet as? CSSStyleSheet)?.cssRules
val rules = (0 until (cssRules?.length ?: 0)).map { val rules = (0 until (cssRules?.length ?: 0)).map {
cssRules?.item(it)?.cssText ?: "" cssRules?.item(it)?.cssText?.replace("\n", "") ?: ""
} }
assertContains( // TODO: we need to come up with test that not relying on any kind of formatting
rules, assertEquals(
""" "@keyframes AnimationsStyleSheet-bounce {0% { transform: translateX(50%); }100% { transform: translateX(-50%); }}",
@keyframes AnimationsStyleSheet-bounce { rules[0].replace(" 0%", "0%").replace(" 100%", "100%"),
0% { transform: translateX(50%); }
100% { transform: translateX(-50%); }
}
""".trimIndent(),
"Animation keyframes wasn't injected correctly" "Animation keyframes wasn't injected correctly"
) )
assertContains(
rules, assertEquals(
""" ".AnimationsStyleSheet-animationClass { animation: 2s ease-in 0s 1 alternate none running AnimationsStyleSheet-bounce; }".trimIndent(),
.AnimationsStyleSheet-animationClass { animation: 2s ease-in 0s 1 alternate none running AnimationsStyleSheet-bounce; } rules[1],
""".trimIndent(),
"Animation class wasn't injected correctly" "Animation class wasn't injected correctly"
) )
} }

Loading…
Cancel
Save