package renderers.html import junit.framework.Assert.assertEquals import kotlinx.html.body import kotlinx.html.html import kotlinx.html.stream.createHTML import org.jetbrains.dokka.base.renderers.html.buildBreakableText import org.junit.jupiter.api.Test class FormattingUtilsTest { @Test fun `should build breakable text`(){ val testedText = "kotlinx.collections.immutable" val expectedHtml = """ kotlinx.collections.immutable """.trimIndent() val html = createHTML(prettyPrint = true).html { body { buildBreakableText(testedText) } } assertEquals(expectedHtml.trim(), html.trim()) } @Test fun `should build breakable text without empty spans`(){ val testedText = "Package org.jetbrains.dokka.it.moduleC" val expectedHtml = """ Package org.jetbrains.dokka.it.moduleC """.trimIndent() val html = createHTML(prettyPrint = true).html { body { buildBreakableText(testedText) } } assertEquals(expectedHtml.trim(), html.trim()) } @Test fun `should build breakable text for text with braces`(){ val testedText = "[Common]kotlinx.collections.immutable" val expectedHtml = """ [Common]kotlinx.collections.immutable """.trimIndent() val html = createHTML(prettyPrint = true).html { body { buildBreakableText(testedText) } } assertEquals(expectedHtml.trim(), html.trim()) } @Test fun `should build breakable text for camel case notation`(){ val testedText = "DokkkkkkkaIsTheBest" val expectedHtml = """ DokkkkkkkaIsTheBest """.trimIndent() val html = createHTML(prettyPrint = true).html { body { buildBreakableText(testedText) } } assertEquals(expectedHtml.trim(), html.trim()) } }