Browse Source

Move relevant border test from StaticComposableTests to CSSBorderTests

pull/893/head
Shagen Ogandzhanian 3 years ago
parent
commit
153ce9f063
  1. 35
      web/core/src/jsTest/kotlin/StaticComposableTests.kt
  2. 85
      web/core/src/jsTest/kotlin/css/CSSBorderTests.kt

35
web/core/src/jsTest/kotlin/StaticComposableTests.kt

@ -90,41 +90,6 @@ class StaticComposableTests {
assertEquals("opacity: 0.2; color: green;", (root.children[0] as HTMLElement).style.cssText)
}
@Test
fun stylesBorder() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
Div(
{
style {
property("border", "1px solid red")
}
}
)
Div(
{
style {
border(3.px, color = Color("green"))
}
}
)
}
assertEquals("border: 1px solid red;", (root.children[0] as HTMLElement).style.cssText)
root.children[1]?.let {
val el = it.unsafeCast<HTMLElement>()
assertEquals(
"green",
el.style.getPropertyValue("border-color")
)
assertEquals(
"3px",
el.style.getPropertyValue("border-width"),
)
}
}
@Test
fun stylesTop() {

85
web/core/src/jsTest/kotlin/css/CSSBorderTests.kt

@ -16,87 +16,48 @@ import kotlin.test.assertEquals
class CSSBorderTests {
@Test
fun borderRadius() = runTest {
fun border() = runTest {
composition {
Div(
{
style {
borderRadius(3.px)
}
}
)
Div(
{
style {
borderRadius(3.px, 5.px)
}
}
)
Div(
{
style {
borderRadius(3.px, 5.px, 4.px)
Div({ style { property("border", "1px solid red") } })
Div({ style { border(3.px, color = Color("green")) } })
}
}
)
Div(
{
style {
borderRadius(3.px, 5.px, 4.px, 1.px)
assertEquals("1px solid red", (root.children[0] as HTMLElement).style.border)
root.children[1]?.let {
val el = it.unsafeCast<HTMLElement>()
assertEquals("green", el.style.getPropertyValue("border-color"))
assertEquals("3px", el.style.getPropertyValue("border-width"))
}
}
)
@Test
fun borderRadius() = runTest {
composition {
Div({ style { borderRadius(3.px) } })
Div({ style { borderRadius(3.px, 5.px) } })
Div({ style { borderRadius(3.px, 5.px, 4.px) } })
Div({ style { borderRadius(3.px, 5.px, 4.px, 1.px) } })
}
assertEquals("3px", (root.children[0] as HTMLElement).style.borderRadius)
assertEquals("3px 5px", (root.children[1] as HTMLElement).style.borderRadius)
assertEquals("3px 5px 4px", (root.children[2] as HTMLElement).style.borderRadius)
assertEquals(
"3px 5px 4px 1px",
(root.children[3] as HTMLElement).style.borderRadius
)
assertEquals("3px 5px 4px 1px", (root.children[3] as HTMLElement).style.borderRadius)
}
@Test
fun borderWidth() = runTest {
composition {
Div(
{
style {
borderWidth(2.px)
}
}
)
Div(
{
style {
borderWidth(3.px, 7.px)
}
}
)
Div(
{
style {
borderWidth(3.px, 5.px, 4.px)
}
}
)
Div(
{
style {
borderWidth(3.px, 5.px, 4.px, 2.px)
}
}
)
Div({ style { borderWidth(2.px) } })
Div({ style { borderWidth(3.px, 7.px) } })
Div({ style { borderWidth(3.px, 5.px, 4.px) } })
Div({ style { borderWidth(3.px, 5.px, 4.px, 2.px) } })
}
assertEquals("2px", (root.children[0] as HTMLElement).style.borderWidth)
assertEquals("3px 7px", (root.children[1] as HTMLElement).style.borderWidth)
assertEquals("3px 5px 4px", (root.children[2] as HTMLElement).style.borderWidth)
assertEquals(
"3px 5px 4px 2px",
(root.children[3] as HTMLElement).style.borderWidth
)
assertEquals("3px 5px 4px 2px", (root.children[3] as HTMLElement).style.borderWidth)
}
}
Loading…
Cancel
Save