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

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

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

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

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

Loading…
Cancel
Save