From ab937a9716d9838dbebb39bead9c9ba54fec51bb Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Fri, 11 Jun 2021 12:00:08 +0200 Subject: [PATCH] Introduce test for testing "raw" element creaation --- .../jsTest/kotlin/elements/ElementsTests.kt | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 web/core/src/jsTest/kotlin/elements/ElementsTests.kt diff --git a/web/core/src/jsTest/kotlin/elements/ElementsTests.kt b/web/core/src/jsTest/kotlin/elements/ElementsTests.kt new file mode 100644 index 0000000000..ef71b59df7 --- /dev/null +++ b/web/core/src/jsTest/kotlin/elements/ElementsTests.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. + */ + +package org.jetbrains.compose.web.core.tests.elements + +import androidx.compose.runtime.Composable +import org.jetbrains.compose.web.attributes.AttrsBuilder +import org.jetbrains.compose.web.attributes.Tag +import org.jetbrains.compose.web.core.tests.runTest +import org.jetbrains.compose.web.dom.ContentBuilder +import org.jetbrains.compose.web.dom.TagElement +import org.jetbrains.compose.web.dom.Text +import org.w3c.dom.HTMLElement +import kotlin.test.Test +import kotlin.test.assertEquals + + +class ElementsTests { + @Test + fun rawCreation() = runTest { + @Composable + fun CustomElement( + attrs: AttrsBuilder.() -> Unit, + content: ContentBuilder? = null + ) { + TagElement( + tagName = "custom", + applyAttrs = attrs, + content + ) + } + + composition { + CustomElement({ + id("container") + }) { + Text("CUSTOM") + } + } + + assertEquals("
CUSTOM
", root.outerHTML) + } +} \ No newline at end of file