Browse Source

Use asHtmlElement helper only in TestUtils

TestUtils is a perfect classic name!
BENCHMARKS_USING_CORE_API
Shagen Ogandzhanian 3 years ago
parent
commit
4c252b8196
  1. 9
      web/core/src/jsTest/kotlin/DomSideEffectTests.kt
  2. 6
      web/core/src/jsTest/kotlin/elements/InputsGenerateCorrectHtmlTests.kt
  3. 24
      web/widgets/src/jsTest/ModifierTests.kt

9
web/core/src/jsTest/kotlin/DomSideEffectTests.kt

@ -12,12 +12,8 @@ import kotlin.test.assertEquals
class DomSideEffectTests { class DomSideEffectTests {
@Test @Test
fun canCreateElementsInDomSideEffect() { fun canCreateElementsInDomSideEffect() = runTest {
val root = "div".asHtmlElement() composition {
renderComposable(
root = root
) {
Div { Div {
DomSideEffect { DomSideEffect {
it.appendChild( it.appendChild(
@ -28,6 +24,7 @@ class DomSideEffectTests {
} }
} }
} }
assertEquals( assertEquals(
expected = "<div><div><p>Hello World!</p></div></div>", expected = "<div><div><p>Hello World!</p></div></div>",
actual = root.outerHTML actual = root.outerHTML

6
web/core/src/jsTest/kotlin/elements/InputsGenerateCorrectHtmlTests.kt

@ -505,10 +505,8 @@ class InputsGenerateCorrectHtmlTests {
} }
@Test @Test
fun textAreaWithDefaultValueAndWithoutIt() { fun textAreaWithDefaultValueAndWithoutIt() = runTest {
val root = "div".asHtmlElement() composition {
renderComposable(root = root) {
TextArea() TextArea()
TextArea { TextArea {
defaultValue("not-empty-default-value") defaultValue("not-empty-default-value")

24
web/widgets/src/jsTest/ModifierTests.kt

@ -12,36 +12,24 @@ import kotlin.test.assertTrue
class ModifierTests { class ModifierTests {
@Test @Test
fun backgroundModifier() { fun backgroundModifier() = runTest {
val root = "div".asHtmlElement() {
renderComposable(
root = root
) {
Box( Box(
Modifier.background(Color(255, 0, 0)) Modifier.background(Color(255, 0, 0))
) { } ) { }
} }
val el = root.firstChild assertEquals("background-color: rgb(255, 0, 0);", nextChild().style.cssText)
assertTrue(el is HTMLElement, "element not found")
assertEquals("background-color: rgb(255, 0, 0);", el.style.cssText)
} }
@Test @Test
fun size() { fun size() = runTest {
val root = "div".asHtmlElement() composition {
renderComposable(
root = root
) {
Box( Box(
Modifier.size(40.dp) Modifier.size(40.dp)
) { } ) { }
} }
val el = root.firstChild assertEquals("width: 40px; height: 40px;", nextChild().style.cssText)
assertTrue(el is HTMLElement, "element not found")
assertEquals("width: 40px; height: 40px;", el.style.cssText)
} }
} }

Loading…
Cancel
Save