From 074bc1e4d8cd7a4e8deef7c25a6edb33ee5ae66d Mon Sep 17 00:00:00 2001 From: Philip Wedemann <22521688+hfhbd@users.noreply.github.com> Date: Wed, 21 Feb 2024 06:31:00 +0100 Subject: [PATCH] Use kotlin.test everywhere (#259) Co-authored-by: hfhbd --- .../main/kotlin/kotlinx/html/generate/main.kt | 3 +- src/jsTest/kotlin/generated/gen-tag-tests.kt | 228 +++++++++--------- src/jsTest/kotlin/injector.kt | 11 +- src/jsTest/kotlin/trees.kt | 33 ++- src/jvmTest/kotlin/custom-tag.kt | 1 - src/jvmTest/kotlin/dom-trees.kt | 23 +- src/jvmTest/kotlin/html5-tags.kt | 5 +- src/jvmTest/kotlin/huge.kt | 4 +- src/jvmTest/kotlin/streaming.kt | 67 +++-- src/jvmTest/kotlin/unsafe.kt | 3 +- .../kotlin/generated/gen-tag-tests.kt | 228 +++++++++--------- src/wasmJsTest/kotlin/injector.kt | 11 +- src/wasmJsTest/kotlin/trees.kt | 37 ++- 13 files changed, 321 insertions(+), 333 deletions(-) diff --git a/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt b/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt index f9991ad5..7d42232b 100644 --- a/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt +++ b/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt @@ -270,7 +270,6 @@ private fun generateTagTests(repository: Repository, filePath: String, defaultTa writeKotlinPoet { addImport("kotlinx.browser", "document") addImport("kotlinx.html.dom", "append") - addAliasedImport(ClassName("kotlin.test", "Test"), "test") addType( TypeSpec .classBuilder("JsTagCastTests") @@ -379,4 +378,4 @@ private fun Appendable.writeKotlinPoet(builder: FileSpec.Builder.() -> Unit) { .apply(builder) .build() .writeTo(this) -} \ No newline at end of file +} diff --git a/src/jsTest/kotlin/generated/gen-tag-tests.kt b/src/jsTest/kotlin/generated/gen-tag-tests.kt index 0ed0710a..8cfa5832 100644 --- a/src/jsTest/kotlin/generated/gen-tag-tests.kt +++ b/src/jsTest/kotlin/generated/gen-tag-tests.kt @@ -4,576 +4,576 @@ import kotlinx.html.js.* DO NOT EDIT This file was generated by module generate *******************************************************************************/ +import kotlin.test.Test import kotlinx.browser.document import kotlinx.html.TagConsumer import kotlinx.html.dom.append import org.w3c.dom.HTMLElement -import kotlin.test.Test as test public class JsTagCastTests { public fun wrapper(): TagConsumer = document.body!!.append - @test + @Test public fun testA() { wrapper().a {} } - @test + @Test public fun testAbbr() { wrapper().abbr {} } - @test + @Test public fun testAddress() { wrapper().address {} } - @test + @Test public fun testArea() { wrapper().area {} } - @test + @Test public fun testArticle() { wrapper().article {} } - @test + @Test public fun testAside() { wrapper().aside {} } - @test + @Test public fun testAudio() { wrapper().audio {} } - @test + @Test public fun testB() { wrapper().b {} } - @test + @Test public fun testBase() { wrapper().base {} } - @test + @Test public fun testBdi() { wrapper().bdi {} } - @test + @Test public fun testBdo() { wrapper().bdo {} } - @test + @Test public fun testBlockQuote() { wrapper().blockQuote {} } - @test + @Test public fun testBody() { wrapper().body {} } - @test + @Test public fun testBr() { wrapper().br {} } - @test + @Test public fun testButton() { wrapper().button {} } - @test + @Test public fun testCanvas() { wrapper().canvas {} } - @test + @Test public fun testCaption() { wrapper().caption {} } - @test + @Test public fun testCite() { wrapper().cite {} } - @test + @Test public fun testCode() { wrapper().code {} } - @test + @Test public fun testCol() { wrapper().col {} } - @test + @Test public fun testColGroup() { wrapper().colGroup {} } - @test + @Test public fun testCommand() { wrapper().command {} } - @test + @Test public fun testDataList() { wrapper().dataList {} } - @test + @Test public fun testDd() { wrapper().dd {} } - @test + @Test public fun testDel() { wrapper().del {} } - @test + @Test public fun testDetails() { wrapper().details {} } - @test + @Test public fun testDfn() { wrapper().dfn {} } - @test + @Test public fun testDialog() { wrapper().dialog {} } - @test + @Test public fun testDiv() { wrapper().div {} } - @test + @Test public fun testDl() { wrapper().dl {} } - @test + @Test public fun testDt() { wrapper().dt {} } - @test + @Test public fun testEm() { wrapper().em {} } - @test + @Test public fun testEmbed() { wrapper().embed {} } - @test + @Test public fun testFieldSet() { wrapper().fieldSet {} } - @test + @Test public fun testFigcaption() { wrapper().figcaption {} } - @test + @Test public fun testFigure() { wrapper().figure {} } - @test + @Test public fun testFooter() { wrapper().footer {} } - @test + @Test public fun testForm() { wrapper().form {} } - @test + @Test public fun testH1() { wrapper().h1 {} } - @test + @Test public fun testH2() { wrapper().h2 {} } - @test + @Test public fun testH3() { wrapper().h3 {} } - @test + @Test public fun testH4() { wrapper().h4 {} } - @test + @Test public fun testH5() { wrapper().h5 {} } - @test + @Test public fun testH6() { wrapper().h6 {} } - @test + @Test public fun testHead() { wrapper().head {} } - @test + @Test public fun testHeader() { wrapper().header {} } - @test + @Test public fun testHGroup() { wrapper().hGroup {} } - @test + @Test public fun testHr() { wrapper().hr {} } - @test + @Test public fun testHtml() { wrapper().html {} } - @test + @Test public fun testI() { wrapper().i {} } - @test + @Test public fun testIframe() { wrapper().iframe {} } - @test + @Test public fun testImg() { wrapper().img {} } - @test + @Test public fun testInput() { wrapper().input {} } - @test + @Test public fun testIns() { wrapper().ins {} } - @test + @Test public fun testKbd() { wrapper().kbd {} } - @test + @Test public fun testKeyGen() { wrapper().keyGen {} } - @test + @Test public fun testLabel() { wrapper().label {} } - @test + @Test public fun testLegend() { wrapper().legend {} } - @test + @Test public fun testLi() { wrapper().li {} } - @test + @Test public fun testLink() { wrapper().link {} } - @test + @Test public fun testMain() { wrapper().main {} } - @test + @Test public fun testMap() { wrapper().map {} } - @test + @Test public fun testMark() { wrapper().mark {} } - @test + @Test public fun testMath() { wrapper().math {} } - @test + @Test public fun testMathml() { wrapper().mathml {} } - @test + @Test public fun testMeta() { wrapper().meta {} } - @test + @Test public fun testMeter() { wrapper().meter {} } - @test + @Test public fun testNav() { wrapper().nav {} } - @test + @Test public fun testNoScript() { wrapper().noScript {} } - @test + @Test public fun testHtmlObject() { wrapper().htmlObject {} } - @test + @Test public fun testOl() { wrapper().ol {} } - @test + @Test public fun testOptGroup() { wrapper().optGroup {} } - @test + @Test public fun testOption() { wrapper().option {} } - @test + @Test public fun testOutput() { wrapper().output {} } - @test + @Test public fun testP() { wrapper().p {} } - @test + @Test public fun testParam() { wrapper().param {} } - @test + @Test public fun testPicture() { wrapper().picture {} } - @test + @Test public fun testPre() { wrapper().pre {} } - @test + @Test public fun testProgress() { wrapper().progress {} } - @test + @Test public fun testQ() { wrapper().q {} } - @test + @Test public fun testRp() { wrapper().rp {} } - @test + @Test public fun testRt() { wrapper().rt {} } - @test + @Test public fun testRuby() { wrapper().ruby {} } - @test + @Test public fun testS() { wrapper().s {} } - @test + @Test public fun testSamp() { wrapper().samp {} } - @test + @Test public fun testScript() { wrapper().script {} } - @test + @Test public fun testSection() { wrapper().section {} } - @test + @Test public fun testSelect() { wrapper().select {} } - @test + @Test public fun testSlot() { wrapper().slot {} } - @test + @Test public fun testSmall() { wrapper().small {} } - @test + @Test public fun testSource() { wrapper().source {} } - @test + @Test public fun testSpan() { wrapper().span {} } - @test + @Test public fun testStrong() { wrapper().strong {} } - @test + @Test public fun testStyle() { wrapper().style {} } - @test + @Test public fun testSub() { wrapper().sub {} } - @test + @Test public fun testSummary() { wrapper().summary {} } - @test + @Test public fun testSup() { wrapper().sup {} } - @test + @Test public fun testSvg() { wrapper().svg {} } - @test + @Test public fun testTable() { wrapper().table {} } - @test + @Test public fun testTbody() { wrapper().tbody {} } - @test + @Test public fun testTd() { wrapper().td {} } - @test + @Test public fun testTemplate() { wrapper().template {} } - @test + @Test public fun testTextArea() { wrapper().textArea {} } - @test + @Test public fun testTfoot() { wrapper().tfoot {} } - @test + @Test public fun testTh() { wrapper().th {} } - @test + @Test public fun testThead() { wrapper().thead {} } - @test + @Test public fun testTime() { wrapper().time {} } - @test + @Test public fun testTitle() { wrapper().title {} } - @test + @Test public fun testTr() { wrapper().tr {} } - @test + @Test public fun testU() { wrapper().u {} } - @test + @Test public fun testUl() { wrapper().ul {} } - @test + @Test public fun testHtmlVar() { wrapper().htmlVar {} } - @test + @Test public fun testVideo() { wrapper().video {} } diff --git a/src/jsTest/kotlin/injector.kt b/src/jsTest/kotlin/injector.kt index b1b2b3ac..d253e313 100644 --- a/src/jsTest/kotlin/injector.kt +++ b/src/jsTest/kotlin/injector.kt @@ -8,7 +8,6 @@ import org.w3c.dom.* import kotlinx.browser.* import kotlin.properties.* import kotlin.test.* -import kotlin.test.Test as test class MyBeanWithDiv { var node: HTMLDivElement by Delegates.notNull() @@ -28,7 +27,7 @@ class InjectToLateInitVarBean { } class InjectorTests { - @test fun injectByClass() { + @Test fun injectByClass() { val bean = MyBeanWithDiv() val node = document.create.inject(bean, listOf( InjectByClassName("my-class") to MyBeanWithDiv::node @@ -42,7 +41,7 @@ class InjectorTests { assertEquals(found, bean.node) } - @test fun injectByClassFailed() { + @Test fun injectByClassFailed() { val bean = MyBeanWithDiv() document.create.inject(bean, listOf( InjectByClassName("my-class") to MyBeanWithDiv::node @@ -58,7 +57,7 @@ class InjectorTests { } } - @test fun injectByTagName() { + @Test fun injectByTagName() { val bean = MyBeanWithP() document.create.inject(bean, listOf( InjectByTagName("p") to MyBeanWithP::p @@ -70,7 +69,7 @@ class InjectorTests { assertEquals("P", bean.p.tagName) } - @test fun injectToLateInitVar() { + @Test fun injectToLateInitVar() { val bean = InjectToLateInitVarBean() document.create.inject(bean, listOf( InjectByTagName("p") to InjectToLateInitVarBean::myP @@ -82,7 +81,7 @@ class InjectorTests { assertEquals("P", bean.myP.tagName) } - @test fun exampleFromWiki() { + @Test fun exampleFromWiki() { val bean = ExampleBean() document.create.inject(bean, listOf( diff --git a/src/jsTest/kotlin/trees.kt b/src/jsTest/kotlin/trees.kt index 1e7197a0..dbae5441 100644 --- a/src/jsTest/kotlin/trees.kt +++ b/src/jsTest/kotlin/trees.kt @@ -7,10 +7,9 @@ import kotlinx.html.js.* import org.w3c.dom.* import kotlinx.browser.* import kotlin.test.* -import kotlin.test.Test as test class DomTreeImplTest { - @test fun simpleTree() { + @Test fun simpleTree() { val node = document.body!!.append.div { p { +"test" @@ -25,7 +24,7 @@ class DomTreeImplTest { assertEquals(node, document.body!!.children.asList().last()) } - @test fun appendSingleNode() { + @Test fun appendSingleNode() { val myDiv: HTMLDivElement = document.body!!.append.div { p { +"test" @@ -37,9 +36,9 @@ class DomTreeImplTest { assertEquals("

test

", myDiv.outerHTML.replace("\\s+".toRegex(), "")) } - @test fun appendNodeWithEventHandler() { + @Test fun appendNodeWithEventHandler() { var clicked = false - + document.body!!.append.div { onClickFunction = { clicked = true @@ -56,11 +55,11 @@ class DomTreeImplTest { } } } - + assertTrue(clicked) } - @test fun testAtMainPage() { + @Test fun testAtMainPage() { document.body!!.append.div { id = "container" } @@ -82,7 +81,7 @@ class DomTreeImplTest { assertEquals("", container.innerHTML) } - @test fun appendMultipleNodes() { + @Test fun appendMultipleNodes() { val wrapper = wrapper() val nodes = wrapper.append { @@ -102,7 +101,7 @@ class DomTreeImplTest { assertEquals("
div1
div2
", wrapper.innerHTML) } - @test fun appendEntity() { + @Test fun appendEntity() { val wrapper = wrapper() wrapper.append.span { +Entities.nbsp @@ -111,7 +110,7 @@ class DomTreeImplTest { assertEquals(" ", wrapper.innerHTML) } - @test fun pastTagAttributeChangedShouldBeProhibited() { + @Test fun pastTagAttributeChangedShouldBeProhibited() { try { document.body!!.append.trace().div { p { @@ -127,7 +126,7 @@ class DomTreeImplTest { } } - @test fun buildBiggerPage() { + @Test fun buildBiggerPage() { val wrapper = wrapper() wrapper.append { @@ -170,7 +169,7 @@ class DomTreeImplTest { """.trimLines(), wrapper.innerHTML) } - @test fun testAppendAndRemoveClass() { + @Test fun testAppendAndRemoveClass() { val wrapper = wrapper() wrapper.append { @@ -183,7 +182,7 @@ class DomTreeImplTest { assertEquals("", wrapper.innerHTML) } - @test fun testSvg() { + @Test fun testSvg() { val wrapper = wrapper() wrapper.append.svg { @@ -193,7 +192,7 @@ class DomTreeImplTest { assertEquals("http://www.w3.org/2000/svg", (wrapper.childNodes.asList() as List).first { it.tagName.lowercase() == "svg" }.namespaceURI) } - @test fun assignEvent() { + @Test fun assignEvent() { val wrapper = wrapper() var invoked = false @@ -216,7 +215,7 @@ class DomTreeImplTest { assertTrue { invoked } } - @test fun testTdThColColGroupCreation() { + @Test fun testTdThColColGroupCreation() { val td = document.create.td() val th = document.create.th() val col = document.create.col() @@ -228,7 +227,7 @@ class DomTreeImplTest { assertEquals("COLGROUP", colGroup.tagName.uppercase()) } - @test fun testPrepend() { + @Test fun testPrepend() { val wrapper = wrapper() wrapper.appendChild(document.createElement("A").apply { textContent = "aaa" }) @@ -241,7 +240,7 @@ class DomTreeImplTest { assertEquals("

OK

aaa", wrapper.innerHTML) } - @test fun testComment() { + @Test fun testComment() { val wrapper = wrapper() wrapper.append.div { comment("commented") diff --git a/src/jvmTest/kotlin/custom-tag.kt b/src/jvmTest/kotlin/custom-tag.kt index 57b91c23..ff1b980f 100644 --- a/src/jvmTest/kotlin/custom-tag.kt +++ b/src/jvmTest/kotlin/custom-tag.kt @@ -2,7 +2,6 @@ package kotlinx.html.tests import kotlinx.html.* import kotlinx.html.stream.* -import org.junit.Test import kotlin.test.* class CustomTagTest { diff --git a/src/jvmTest/kotlin/dom-trees.kt b/src/jvmTest/kotlin/dom-trees.kt index 58f54f58..a44de504 100644 --- a/src/jvmTest/kotlin/dom-trees.kt +++ b/src/jvmTest/kotlin/dom-trees.kt @@ -4,10 +4,9 @@ import kotlinx.html.* import kotlinx.html.consumers.* import kotlinx.html.dom.* import kotlin.test.* -import org.junit.Test as test class TestDOMTrees { - @test fun `able to create simple tree`() { + @Test fun `able to create simple tree`() { val tree = createHTMLDocument().div { id = "test-node" +"content" @@ -16,7 +15,7 @@ class TestDOMTrees { assertEquals("div", tree.getElementById("test-node")?.tagName?.lowercase()) } - @test fun `able to create complex tree and render it with pretty print`() { + @Test fun `able to create complex tree and render it with pretty print`() { val tree = createHTMLDocument().html { body { h1 { @@ -43,7 +42,7 @@ class TestDOMTrees { """.trimIndent(), tree.serialize(true).trim().replace("\r\n", "\n")) } - @test fun `vals create and append support`() { + @Test fun `vals create and append support`() { val document = createHTMLDocument().html { body { div { @@ -74,7 +73,7 @@ class TestDOMTrees { """.trim().replace("\r\n", "\n"), document.serialize(true).trim().replace("\r\n", "\n")) } - @test fun `append function support`() { + @Test fun `append function support`() { val document = createHTMLDocument().html { body { div { @@ -112,7 +111,7 @@ class TestDOMTrees { """.trim().replace("\r\n", "\n"), document.serialize(true).trim().replace("\r\n", "\n")) } - @test fun `should compile wiki example`() { + @Test fun `should compile wiki example`() { println(document { append.filter { if (it.tagName == "div") SKIP else PASS }.html { body { @@ -125,7 +124,7 @@ class TestDOMTrees { }.serialize()) } - @test fun `svg should have namespace`() { + @Test fun `svg should have namespace`() { val d = document { append.html { body { @@ -139,7 +138,7 @@ class TestDOMTrees { d.serialize(false).trim().replace("\r\n", "\n")) } - @test fun `generalize tests`() { + @Test fun `generalize tests`() { fun T.genericFlow() where T : HtmlBlockTag { classes += "aha" +"content" @@ -180,7 +179,7 @@ class TestDOMTrees { } } - @test fun `script content`() { + @Test fun `script content`() { val document = document { append.html { head { @@ -199,7 +198,7 @@ class TestDOMTrees { document.serialize(false).trim().replace("\r\n", "\n")) } - @test fun testPrepend() { + @Test fun testPrepend() { val document = createHTMLDocument().html { body { a { text("aaa") } @@ -217,7 +216,7 @@ class TestDOMTrees { document.serialize(false).trim().replace("\r\n", "\n")) } - @test fun testComment() { + @Test fun testComment() { val document = createHTMLDocument().html { comment("commented") } @@ -226,4 +225,4 @@ class TestDOMTrees { "", document.serialize(false).trim().replace("\r\n", "\n")) } -} \ No newline at end of file +} diff --git a/src/jvmTest/kotlin/html5-tags.kt b/src/jvmTest/kotlin/html5-tags.kt index ede8881c..42e1e22a 100644 --- a/src/jvmTest/kotlin/html5-tags.kt +++ b/src/jvmTest/kotlin/html5-tags.kt @@ -3,7 +3,6 @@ package kotlinx.html.tests import kotlinx.html.* import kotlinx.html.dom.* import kotlin.test.* -import org.junit.Test as test class Html5TagsTest { @Test @@ -35,7 +34,7 @@ class Html5TagsTest { ) } - @test + @Test fun `able to create complex tree and render it with pretty print`() { val tree = createHTMLDocument().html { body { @@ -68,4 +67,4 @@ class Html5TagsTest { """.trimIndent(), serialize.trim().replace("\r\n", "\n") ) } -} \ No newline at end of file +} diff --git a/src/jvmTest/kotlin/huge.kt b/src/jvmTest/kotlin/huge.kt index 56bd3554..42af7742 100644 --- a/src/jvmTest/kotlin/huge.kt +++ b/src/jvmTest/kotlin/huge.kt @@ -2,7 +2,7 @@ package kotlinx.html.tests import kotlinx.html.* import kotlinx.html.stream.* -import org.junit.* +import kotlin.test.* import kotlin.system.* open class HugeStreamingBenchmark { @@ -105,4 +105,4 @@ open class HugeStreamingBenchmark { } } } -} \ No newline at end of file +} diff --git a/src/jvmTest/kotlin/streaming.kt b/src/jvmTest/kotlin/streaming.kt index 9bf62394..4f50d7fb 100644 --- a/src/jvmTest/kotlin/streaming.kt +++ b/src/jvmTest/kotlin/streaming.kt @@ -5,10 +5,9 @@ import kotlinx.html.consumers.* import kotlinx.html.stream.* import java.io.* import kotlin.test.* -import org.junit.Test as test class TestStreaming { - @test fun `we should be able to construct at least simple things`() { + @Test fun `we should be able to construct at least simple things`() { assertEquals( "\n \n

Test me

\n \n\n", StringBuilder().apply { @@ -22,7 +21,7 @@ class TestStreaming { }.toString()) } - @test fun `we should be able append multiple htmls`() { + @Test fun `we should be able append multiple htmls`() { assertEquals( "\n \n

Test me

\n \n\n\n", StringBuilder().apply { @@ -39,7 +38,7 @@ class TestStreaming { }.toString()) } - @test(expected = IllegalStateException::class) + @Test(expected = IllegalStateException::class) fun `we shouldn't be able to change attributes of other tag`() { StringBuilder().apply { appendHTML().html { @@ -52,7 +51,7 @@ class TestStreaming { } } - @test fun `we should be able to write to different appendable`() { + @Test fun `we should be able to write to different appendable`() { val sw = StringWriter() val result = sw.appendHTML(false).html { body { @@ -65,7 +64,7 @@ class TestStreaming { assertEquals("

Kotlin

", sw2.toString()) } - @test fun `we should be able filter tags`() { + @Test fun `we should be able filter tags`() { val sw = StringWriter() val result = sw.appendHTML(false).filter { @@ -106,7 +105,7 @@ class TestStreaming { assertEquals("

[footer.p][footer.p.span.a]

", sw2.toString()) } - @test fun `we should be able to handle many requests`() { + @Test fun `we should be able to handle many requests`() { for (i in 1..1000000) { NullAppendable.appendHTML().html { body { @@ -137,16 +136,16 @@ class TestStreaming { } } - @test fun `we should be able to make extension functions with DSL`() { + @Test fun `we should be able to make extension functions with DSL`() { assertEquals("", StringBuilder().appendHTML(false).buildMe().toString()) } - @test fun `empty tag should have attributes`() { + @Test fun `empty tag should have attributes`() { assertEquals("
", StringBuilder().appendHTML(false).div { id = "d" }.toString()) assertEquals("
", StringBuilder().appendHTML(false).div { id = "d"; div { id = "d2" } }.toString()) } - @test fun `test attributes order`() { + @Test fun `test attributes order`() { val order1 = StringBuilder().appendHTML(false).html { body { div { @@ -168,7 +167,7 @@ class TestStreaming { assertNotEquals(order1, order2) } - @test fun `multiple attributes and custom attribute present`() { + @Test fun `multiple attributes and custom attribute present`() { assertEquals("
", StringBuilder().appendHTML(false).div { id = "d1" attributes["custom"] = "c1" @@ -176,24 +175,24 @@ class TestStreaming { }.toString()) } - @test fun `test tags order`() { + @Test fun `test tags order`() { assertEquals("

", StringBuilder().appendHTML(false).div { p { span {} } }.toString()) } - @test fun `test generated enum could be used`() { + @Test fun `test generated enum could be used`() { assertEquals("", StringBuilder().appendHTML(false).link { rel = LinkRel.stylesheet href = "/path" }.toString()) } - @test fun `anchor with href syntax`() { + @Test fun `anchor with href syntax`() { assertEquals("text", StringBuilder().appendHTML(false).a("a.html") { +"text" }.toString()) } - @test fun `multiple content`() { + @Test fun `multiple content`() { assertEquals("AAAbbb...", StringBuilder().appendHTML(false).span { +"AAA" +"bbb." @@ -201,7 +200,7 @@ class TestStreaming { }.toString()) } - @test fun `content with entity`() { + @Test fun `content with entity`() { assertEquals("before&after", StringBuilder().appendHTML(false).span { +"before" +Entities.amp @@ -209,7 +208,7 @@ class TestStreaming { }.toString()) } - @test fun `test form with button`() { + @Test fun `test form with button`() { assertEquals("
" + "var1" + "var2" + @@ -230,7 +229,7 @@ class TestStreaming { }.toString()) } - @test fun `test measure consumer with loop inside`() { + @Test fun `test measure consumer with loop inside`() { val count = 1000 val builder = StringBuilder(26 * (count + 1)).appendHTML(false) @@ -272,7 +271,7 @@ class TestStreaming { assertEquals(expected.toString(), rs.result.toString()) } - @test fun `escape bad chars`() { + @Test fun `escape bad chars`() { assertEquals("
" + "content<script>" + "
", @@ -284,21 +283,21 @@ class TestStreaming { }.toString()) } - @test(expected = IllegalArgumentException::class) + @Test(expected = IllegalArgumentException::class) fun `bad chars in attribute name`() { StringBuilder().appendHTML().div { attributes["bad'char"] = "test" } } - @test(expected = IllegalArgumentException::class) + @Test(expected = IllegalArgumentException::class) fun `bad chars 'equals' in attribute name`() { StringBuilder().appendHTML().div { attributes["bad=char"] = "test" } } - @test(expected = IllegalStateException::class) + @Test(expected = IllegalStateException::class) fun `attribute values couldn't be changed after tag content`() { createHTML().div { +"content" @@ -306,20 +305,20 @@ class TestStreaming { } } - @test fun `we should print empty tags with no close tag`() { + @Test fun `we should print empty tags with no close tag`() { assertEquals("", StringBuilder().appendHTML( prettyPrint = false ).img(src = "my.jpg").toString()) } - @test fun `we should print empty tags with close tag if xhtmlCompatible flag is set to true`() { + @Test fun `we should print empty tags with close tag if xhtmlCompatible flag is set to true`() { assertEquals("", StringBuilder().appendHTML( prettyPrint = false, xhtmlCompatible = true ).img(src = "my.jpg").toString()) } - @test fun `pretty print should take into account inline tags`() { + @Test fun `pretty print should take into account inline tags`() { val text = StringBuilder().apply { appendHTML().div { +"content" @@ -332,7 +331,7 @@ class TestStreaming { assertEquals("
contenty
", text.trim()) } - @test fun `pretty print should work`() { + @Test fun `pretty print should work`() { assertEquals("
\n" + "
content
\n" + "
\n" + @@ -350,7 +349,7 @@ class TestStreaming { }.toString().trim()) } - @test fun `ticker attribute modification should work properly`() { + @Test fun `ticker attribute modification should work properly`() { assertEquals("", createHTML(false).input { type = InputType.checkBox checked = true @@ -363,21 +362,21 @@ class TestStreaming { }) } - @test fun `meta tag should have name and content suggested attributes`() { + @Test fun `meta tag should have name and content suggested attributes`() { assertEquals("", createHTML(false).meta("name", "content")) assertEquals("", createHTML(false).head { meta("name", "content") }) } - @test fun `we should be able to create div with no body`() { + @Test fun `we should be able to create div with no body`() { assertEquals("
", createHTML(false).div()) assertEquals("
", createHTML(false).div { div() }) } - @test fun `meta tag example`() { + @Test fun `meta tag example`() { createHTML(true).html { head { meta { @@ -391,7 +390,7 @@ class TestStreaming { } } - @test fun `svg should have namespace`() { + @Test fun `svg should have namespace`() { val t = createHTML(false).html { body { svg { @@ -402,7 +401,7 @@ class TestStreaming { assertEquals("", t) } - @test fun `pretty print`() { + @Test fun `pretty print`() { val x = StringBuilder().appendHTML().html { body { article { @@ -427,7 +426,7 @@ class TestStreaming { """.trimIndent(), x.trimEnd()) } - @test fun testHtmlWithNamespace() { + @Test fun testHtmlWithNamespace() { val x = createHTML().html(namespace = "test") { body { } @@ -440,7 +439,7 @@ class TestStreaming { """.trimIndent(), x.trimEnd()) } - @test fun testComment() { + @Test fun testComment() { val x = createHTML().html { comment("commented") body { } diff --git a/src/jvmTest/kotlin/unsafe.kt b/src/jvmTest/kotlin/unsafe.kt index d58f90ab..7008baab 100644 --- a/src/jvmTest/kotlin/unsafe.kt +++ b/src/jvmTest/kotlin/unsafe.kt @@ -1,7 +1,6 @@ import kotlinx.html.* import kotlinx.html.dom.* import kotlinx.html.stream.* -import org.junit.Test import kotlin.test.* class UnsafeContentTest { @@ -74,4 +73,4 @@ class UnsafeContentTest { assertEquals("

para

", tree.documentElement.serialize(false)) } -} \ No newline at end of file +} diff --git a/src/wasmJsTest/kotlin/generated/gen-tag-tests.kt b/src/wasmJsTest/kotlin/generated/gen-tag-tests.kt index 9ce12862..63660568 100644 --- a/src/wasmJsTest/kotlin/generated/gen-tag-tests.kt +++ b/src/wasmJsTest/kotlin/generated/gen-tag-tests.kt @@ -4,576 +4,576 @@ import kotlinx.html.js.* DO NOT EDIT This file was generated by module generate *******************************************************************************/ +import kotlin.test.Test import kotlinx.browser.document import kotlinx.html.TagConsumer import kotlinx.html.dom.append import org.w3c.dom.Element -import kotlin.test.Test as test public class JsTagCastTests { public fun wrapper(): TagConsumer = document.body!!.append - @test + @Test public fun testA() { wrapper().a {} } - @test + @Test public fun testAbbr() { wrapper().abbr {} } - @test + @Test public fun testAddress() { wrapper().address {} } - @test + @Test public fun testArea() { wrapper().area {} } - @test + @Test public fun testArticle() { wrapper().article {} } - @test + @Test public fun testAside() { wrapper().aside {} } - @test + @Test public fun testAudio() { wrapper().audio {} } - @test + @Test public fun testB() { wrapper().b {} } - @test + @Test public fun testBase() { wrapper().base {} } - @test + @Test public fun testBdi() { wrapper().bdi {} } - @test + @Test public fun testBdo() { wrapper().bdo {} } - @test + @Test public fun testBlockQuote() { wrapper().blockQuote {} } - @test + @Test public fun testBody() { wrapper().body {} } - @test + @Test public fun testBr() { wrapper().br {} } - @test + @Test public fun testButton() { wrapper().button {} } - @test + @Test public fun testCanvas() { wrapper().canvas {} } - @test + @Test public fun testCaption() { wrapper().caption {} } - @test + @Test public fun testCite() { wrapper().cite {} } - @test + @Test public fun testCode() { wrapper().code {} } - @test + @Test public fun testCol() { wrapper().col {} } - @test + @Test public fun testColGroup() { wrapper().colGroup {} } - @test + @Test public fun testCommand() { wrapper().command {} } - @test + @Test public fun testDataList() { wrapper().dataList {} } - @test + @Test public fun testDd() { wrapper().dd {} } - @test + @Test public fun testDel() { wrapper().del {} } - @test + @Test public fun testDetails() { wrapper().details {} } - @test + @Test public fun testDfn() { wrapper().dfn {} } - @test + @Test public fun testDialog() { wrapper().dialog {} } - @test + @Test public fun testDiv() { wrapper().div {} } - @test + @Test public fun testDl() { wrapper().dl {} } - @test + @Test public fun testDt() { wrapper().dt {} } - @test + @Test public fun testEm() { wrapper().em {} } - @test + @Test public fun testEmbed() { wrapper().embed {} } - @test + @Test public fun testFieldSet() { wrapper().fieldSet {} } - @test + @Test public fun testFigcaption() { wrapper().figcaption {} } - @test + @Test public fun testFigure() { wrapper().figure {} } - @test + @Test public fun testFooter() { wrapper().footer {} } - @test + @Test public fun testForm() { wrapper().form {} } - @test + @Test public fun testH1() { wrapper().h1 {} } - @test + @Test public fun testH2() { wrapper().h2 {} } - @test + @Test public fun testH3() { wrapper().h3 {} } - @test + @Test public fun testH4() { wrapper().h4 {} } - @test + @Test public fun testH5() { wrapper().h5 {} } - @test + @Test public fun testH6() { wrapper().h6 {} } - @test + @Test public fun testHead() { wrapper().head {} } - @test + @Test public fun testHeader() { wrapper().header {} } - @test + @Test public fun testHGroup() { wrapper().hGroup {} } - @test + @Test public fun testHr() { wrapper().hr {} } - @test + @Test public fun testHtml() { wrapper().html {} } - @test + @Test public fun testI() { wrapper().i {} } - @test + @Test public fun testIframe() { wrapper().iframe {} } - @test + @Test public fun testImg() { wrapper().img {} } - @test + @Test public fun testInput() { wrapper().input {} } - @test + @Test public fun testIns() { wrapper().ins {} } - @test + @Test public fun testKbd() { wrapper().kbd {} } - @test + @Test public fun testKeyGen() { wrapper().keyGen {} } - @test + @Test public fun testLabel() { wrapper().label {} } - @test + @Test public fun testLegend() { wrapper().legend {} } - @test + @Test public fun testLi() { wrapper().li {} } - @test + @Test public fun testLink() { wrapper().link {} } - @test + @Test public fun testMain() { wrapper().main {} } - @test + @Test public fun testMap() { wrapper().map {} } - @test + @Test public fun testMark() { wrapper().mark {} } - @test + @Test public fun testMath() { wrapper().math {} } - @test + @Test public fun testMathml() { wrapper().mathml {} } - @test + @Test public fun testMeta() { wrapper().meta {} } - @test + @Test public fun testMeter() { wrapper().meter {} } - @test + @Test public fun testNav() { wrapper().nav {} } - @test + @Test public fun testNoScript() { wrapper().noScript {} } - @test + @Test public fun testHtmlObject() { wrapper().htmlObject {} } - @test + @Test public fun testOl() { wrapper().ol {} } - @test + @Test public fun testOptGroup() { wrapper().optGroup {} } - @test + @Test public fun testOption() { wrapper().option {} } - @test + @Test public fun testOutput() { wrapper().output {} } - @test + @Test public fun testP() { wrapper().p {} } - @test + @Test public fun testParam() { wrapper().param {} } - @test + @Test public fun testPicture() { wrapper().picture {} } - @test + @Test public fun testPre() { wrapper().pre {} } - @test + @Test public fun testProgress() { wrapper().progress {} } - @test + @Test public fun testQ() { wrapper().q {} } - @test + @Test public fun testRp() { wrapper().rp {} } - @test + @Test public fun testRt() { wrapper().rt {} } - @test + @Test public fun testRuby() { wrapper().ruby {} } - @test + @Test public fun testS() { wrapper().s {} } - @test + @Test public fun testSamp() { wrapper().samp {} } - @test + @Test public fun testScript() { wrapper().script {} } - @test + @Test public fun testSection() { wrapper().section {} } - @test + @Test public fun testSelect() { wrapper().select {} } - @test + @Test public fun testSlot() { wrapper().slot {} } - @test + @Test public fun testSmall() { wrapper().small {} } - @test + @Test public fun testSource() { wrapper().source {} } - @test + @Test public fun testSpan() { wrapper().span {} } - @test + @Test public fun testStrong() { wrapper().strong {} } - @test + @Test public fun testStyle() { wrapper().style {} } - @test + @Test public fun testSub() { wrapper().sub {} } - @test + @Test public fun testSummary() { wrapper().summary {} } - @test + @Test public fun testSup() { wrapper().sup {} } - @test + @Test public fun testSvg() { wrapper().svg {} } - @test + @Test public fun testTable() { wrapper().table {} } - @test + @Test public fun testTbody() { wrapper().tbody {} } - @test + @Test public fun testTd() { wrapper().td {} } - @test + @Test public fun testTemplate() { wrapper().template {} } - @test + @Test public fun testTextArea() { wrapper().textArea {} } - @test + @Test public fun testTfoot() { wrapper().tfoot {} } - @test + @Test public fun testTh() { wrapper().th {} } - @test + @Test public fun testThead() { wrapper().thead {} } - @test + @Test public fun testTime() { wrapper().time {} } - @test + @Test public fun testTitle() { wrapper().title {} } - @test + @Test public fun testTr() { wrapper().tr {} } - @test + @Test public fun testU() { wrapper().u {} } - @test + @Test public fun testUl() { wrapper().ul {} } - @test + @Test public fun testHtmlVar() { wrapper().htmlVar {} } - @test + @Test public fun testVideo() { wrapper().video {} } diff --git a/src/wasmJsTest/kotlin/injector.kt b/src/wasmJsTest/kotlin/injector.kt index b5510c6c..effe64fa 100644 --- a/src/wasmJsTest/kotlin/injector.kt +++ b/src/wasmJsTest/kotlin/injector.kt @@ -6,7 +6,6 @@ import org.w3c.dom.* import kotlinx.browser.* import kotlin.properties.* import kotlin.test.* -import kotlin.test.Test as test class MyBeanWithDiv { var node: HTMLDivElement by Delegates.notNull() @@ -26,7 +25,7 @@ class InjectToLateInitVarBean { } class InjectorTests { - @test fun injectByClass() { + @Test fun injectByClass() { val bean = MyBeanWithDiv() val node = document.create.inject(bean, listOf( InjectByClassName("my-class") to MyBeanWithDiv::node @@ -40,7 +39,7 @@ class InjectorTests { assertEquals(found, bean.node) } - @test fun injectByClassFailed() { + @Test fun injectByClassFailed() { val bean = MyBeanWithDiv() document.create.inject(bean, listOf( InjectByClassName("my-class") to MyBeanWithDiv::node @@ -56,7 +55,7 @@ class InjectorTests { } } - @test fun injectByTagName() { + @Test fun injectByTagName() { val bean = MyBeanWithP() document.create.inject(bean, listOf( InjectByTagName("p") to MyBeanWithP::p @@ -68,7 +67,7 @@ class InjectorTests { assertEquals("P", bean.p.tagName) } - @test fun injectToLateInitVar() { + @Test fun injectToLateInitVar() { val bean = InjectToLateInitVarBean() document.create.inject(bean, listOf( InjectByTagName("p") to InjectToLateInitVarBean::myP @@ -80,7 +79,7 @@ class InjectorTests { assertEquals("P", bean.myP.tagName) } - @test fun exampleFromWiki() { + @Test fun exampleFromWiki() { val bean = ExampleBean() document.create.inject(bean, listOf( diff --git a/src/wasmJsTest/kotlin/trees.kt b/src/wasmJsTest/kotlin/trees.kt index deffb1bb..d9413826 100644 --- a/src/wasmJsTest/kotlin/trees.kt +++ b/src/wasmJsTest/kotlin/trees.kt @@ -31,13 +31,10 @@ import org.w3c.dom.HTMLFormElement import org.w3c.dom.asList import org.w3c.dom.get import org.w3c.dom.svg.SVGElement -import kotlin.test.assertEquals -import kotlin.test.assertTrue -import kotlin.test.fail -import kotlin.test.Test as test +import kotlin.test.* class DomTreeImplTest { - @test fun simpleTree() { + @Test fun simpleTree() { val node = document.body!!.append.div { p { +"test" @@ -52,7 +49,7 @@ class DomTreeImplTest { assertEquals(node, document.body!!.children.asList().last()) } - @test fun appendSingleNode() { + @Test fun appendSingleNode() { val myDiv: HTMLDivElement = document.body!!.append.div { p { +"test" @@ -64,9 +61,9 @@ class DomTreeImplTest { assertEquals("

test

", myDiv.outerHTML.replace("\\s+".toRegex(), "")) } - @test fun appendNodeWithEventHandler() { + @Test fun appendNodeWithEventHandler() { var clicked = false - + document.body!!.append.div { id = "clickable" onClickFunction = { @@ -81,11 +78,11 @@ class DomTreeImplTest { it.click() } } - + assertTrue(clicked) } - @test fun testAtMainPage() { + @Test fun testAtMainPage() { document.body!!.append.div { id = "container" } @@ -107,7 +104,7 @@ class DomTreeImplTest { assertEquals("", container.innerHTML) } - @test fun appendMultipleNodes() { + @Test fun appendMultipleNodes() { val wrapper = wrapper() val nodes = wrapper.append { @@ -127,7 +124,7 @@ class DomTreeImplTest { assertEquals("
div1
div2
", wrapper.innerHTML) } - @test fun appendEntity() { + @Test fun appendEntity() { val wrapper = wrapper() wrapper.append.span { +Entities.nbsp @@ -136,7 +133,7 @@ class DomTreeImplTest { assertEquals(" ", wrapper.innerHTML) } - @test fun pastTagAttributeChangedShouldBeProhibited() { + @Test fun pastTagAttributeChangedShouldBeProhibited() { try { document.body!!.append.trace().div { p { @@ -152,7 +149,7 @@ class DomTreeImplTest { } } - @test fun buildBiggerPage() { + @Test fun buildBiggerPage() { val wrapper = wrapper() wrapper.append { @@ -195,7 +192,7 @@ class DomTreeImplTest {
""".trimLines(), wrapper.innerHTML) } - @test fun testAppendAndRemoveClass() { + @Test fun testAppendAndRemoveClass() { val wrapper = wrapper() wrapper.append { @@ -208,7 +205,7 @@ class DomTreeImplTest { assertEquals("", wrapper.innerHTML) } - @test fun testSvg() { + @Test fun testSvg() { val wrapper = wrapper() wrapper.append.svg { @@ -221,7 +218,7 @@ class DomTreeImplTest { assertEquals("http://www.w3.org/2000/svg", svg.namespaceURI) } - @test fun assignEvent() { + @Test fun assignEvent() { val wrapper = wrapper() var invoked = false @@ -244,7 +241,7 @@ class DomTreeImplTest { assertTrue { invoked } } - @test fun testTdThColColGroupCreation() { + @Test fun testTdThColColGroupCreation() { val td = document.create.td() val th = document.create.th() val col = document.create.col() @@ -256,7 +253,7 @@ class DomTreeImplTest { assertEquals("COLGROUP", colGroup.tagName.uppercase()) } - @test fun testPrepend() { + @Test fun testPrepend() { val wrapper = wrapper() wrapper.appendChild(document.createElement("A").apply { textContent = "aaa" }) @@ -269,7 +266,7 @@ class DomTreeImplTest { assertEquals("

OK

aaa", wrapper.innerHTML) } - @test fun testComment() { + @Test fun testComment() { val wrapper = wrapper() wrapper.append.div { comment("commented")