diff --git a/platform/jewel/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt b/platform/jewel/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt index 5f1f5a9ecee9e..bfc18429d436b 100644 --- a/platform/jewel/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt +++ b/platform/jewel/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt @@ -23,24 +23,28 @@ public fun List.assertEquals(vararg expected: MarkdownBlock) { ) } -public fun List.findDifferences(expected: List, indentSize: Int): List = buildList { - val indent = " ".repeat(indentSize) - val thisSize = this@findDifferences.size - if (expected.size != thisSize) { - add("$indent * Content size mismatch. Was $thisSize, but we expected ${expected.size}") - add("$indent Actual: ${this@findDifferences}") - add("$indent Expected: $expected\n") - add("$indent ℹ️ Note: skipping cells comparison as it's meaningless") - return@buildList - } +public fun List.findDifferences(expected: List, indentSize: Int): List = + buildList { + val indent = " ".repeat(indentSize) + val thisSize = this@findDifferences.size + if (expected.size != thisSize) { + add("$indent * Content size mismatch. Was $thisSize, but we expected ${expected.size}") + add("$indent Actual: ${this@findDifferences}") + add("$indent Expected: $expected\n") + add("$indent ℹ️ Note: skipping cells comparison as it's meaningless") + return@buildList + } - for ((i, item) in this@findDifferences.withIndex()) { - val difference = item.findDifferenceWith(expected[i], indentSize + 2) - if (difference.isNotEmpty()) { - add("$indent * Item #$i is not the same as the expected value.\n\n" + "${difference.joinToString("\n")}\n") + for ((i, item) in this@findDifferences.withIndex()) { + val difference = item.findDifferenceWith(expected[i], indentSize + 2) + if (difference.isNotEmpty()) { + add( + "$indent * Item #$i is not the same as the expected value.\n\n" + + "${difference.joinToString("\n")}\n" + ) + } } } -} private fun MarkdownBlock.findDifferenceWith(expected: MarkdownBlock, indentSize: Int): List { val indent = " ".repeat(indentSize) @@ -168,19 +172,25 @@ private fun diffList(actual: ListBlock, expected: MarkdownBlock, indentSize: Int public fun paragraph(content: String): Paragraph = Paragraph(InlineMarkdown.Text(content)) -public fun heading(level: Int, vararg inlineContent: InlineMarkdown): Heading = Heading(inlineContent = inlineContent, level = level) +public fun heading(level: Int, vararg inlineContent: InlineMarkdown): Heading = + Heading(inlineContent = inlineContent, level = level) public fun indentedCodeBlock(content: String): IndentedCodeBlock = IndentedCodeBlock(content) -public fun fencedCodeBlock(content: String, mimeType: MimeType? = null): FencedCodeBlock = FencedCodeBlock(content, mimeType) +public fun fencedCodeBlock(content: String, mimeType: MimeType? = null): FencedCodeBlock = + FencedCodeBlock(content, mimeType) public fun blockQuote(vararg contents: MarkdownBlock): BlockQuote = BlockQuote(contents.toList()) public fun unorderedList(vararg items: ListItem, isTight: Boolean = true, marker: String = "-"): UnorderedList = UnorderedList(items.toList(), isTight, marker) -public fun orderedList(vararg items: ListItem, isTight: Boolean = true, startFrom: Int = 1, delimiter: String = "."): OrderedList = - OrderedList(items.toList(), isTight, startFrom, delimiter) +public fun orderedList( + vararg items: ListItem, + isTight: Boolean = true, + startFrom: Int = 1, + delimiter: String = ".", +): OrderedList = OrderedList(items.toList(), isTight, startFrom, delimiter) public fun listItem(vararg items: MarkdownBlock): ListItem = ListItem(*items) diff --git a/platform/jewel/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/tables/GitHubTableProcessorExtension.kt b/platform/jewel/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/tables/GitHubTableProcessorExtension.kt index 21dc1543b80e6..c887fc2893bcb 100644 --- a/platform/jewel/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/tables/GitHubTableProcessorExtension.kt +++ b/platform/jewel/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/tables/GitHubTableProcessorExtension.kt @@ -147,13 +147,13 @@ internal data class TableBlock(val header: TableHeader, val rows: List } } -internal data class TableHeader(val cells: List) : CustomBlock() +internal data class TableHeader(val cells: List) : MarkdownBlock.CustomBlock -internal data class TableRow(val rowIndex: Int, val cells: List) : CustomBlock() +internal data class TableRow(val rowIndex: Int, val cells: List) : MarkdownBlock.CustomBlock internal data class TableCell( val rowIndex: Int, val columnIndex: Int, val content: List, val alignment: Alignment.Horizontal?, -) : CustomBlock() +) : MarkdownBlock.CustomBlock diff --git a/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/BasicJewelUiTest.kt b/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/BasicJewelUiTest.kt index b15d9dbb50086..bc487028375ca 100644 --- a/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/BasicJewelUiTest.kt +++ b/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/BasicJewelUiTest.kt @@ -7,13 +7,13 @@ import kotlinx.coroutines.runBlocking import org.junit.Rule public open class BasicJewelUiTest { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() + @get:Rule public val composeRule: ComposeContentTestRule = createComposeRule() @Suppress("ImplicitUnitReturnType") - protected fun runComposeTest(composable: @Composable () -> Unit, block: suspend ComposeContentTestRule.() -> Unit): Unit = + protected fun runComposeTest(composable: @Composable () -> Unit, block: suspend ComposeContentTestRule.() -> Unit) { runBlocking { composeRule.setContent(composable) composeRule.block() } + } } diff --git a/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt b/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt index 79163f216910d..590ce240ab0c3 100644 --- a/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt +++ b/platform/jewel/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt @@ -29,7 +29,7 @@ import org.junit.Test @Suppress("ImplicitUnitReturnType") public class PainterHintTest : BasicJewelUiTest() { @Test - public fun `empty hint should be ignored`(): Unit = + public fun `empty hint should be ignored`() { runComposeTest({ OverrideDarkMode(isDark = false) { val provider = rememberResourcePainterProvider("icons/github.svg", PainterHintTest::class.java) @@ -46,6 +46,7 @@ public class PainterHintTest : BasicJewelUiTest() { }) { awaitIdle() } + } private class TestPainterProviderScope( density: Density,