Browse Source

Add minimal test for testing media query in stylesheet

pull/807/head 0.5.0-build226
Shagen Ogandzhanian 3 years ago
parent
commit
453cc89bca
  1. 34
      web/core/src/jsTest/kotlin/CSSStylesheetTests.kt

34
web/core/src/jsTest/kotlin/CSSStylesheetTests.kt

@ -5,6 +5,7 @@
package org.jetbrains.compose.web.core.tests
import kotlinx.browser.window
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.Div
import org.w3c.dom.HTMLElement
@ -44,6 +45,24 @@ object AppStylesheet : StyleSheet() {
property("width", AppCSSVariables.width.value())
property("height", AppCSSVariables.height.value())
}
val withMedia by style {
color("lime")
backgroundColor("lime")
media(minWidth(20000.px)) {
self style {
color("red")
}
}
media(minWidth(20.px)) {
self style {
backgroundColor("green")
}
}
}
}
@ -103,4 +122,19 @@ class CSSVariableTests {
assertEquals(100.toDouble(), boundingRect.width)
assertEquals(200.toDouble(), boundingRect.height)
}
@Test
fun withMediaQuery() = runTest {
composition {
Style(AppStylesheet)
Div({
classes(AppStylesheet.withMedia)
})
}
root.children[1]?.let { el ->
assertEquals("rgb(0, 255, 0)", window.getComputedStyle(el).color)
assertEquals("rgb(0, 128, 0)", window.getComputedStyle(el).backgroundColor)
}
}
}
Loading…
Cancel
Save