mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Use asHtmlElement helper only in TestUtils
TestUtils is a perfect classic name!
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user