diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt index c6f80a8ef0..35d0bf6c86 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt @@ -93,7 +93,7 @@ class MarkdownParserTest : InstrumentedTest { @Test fun parseItalic2() { // Riot-Web format - "_italic_".let { markdownParser.parse(it) }.expect("italic", "italic") + "_italic_".let { markdownParser.parse(it).expect(it, "italic") } } /** @@ -113,9 +113,7 @@ class MarkdownParserTest : InstrumentedTest { testType( name = "code", markdownPattern = "`", - htmlExpectedTag = "code", - plainTextPrefix = "\"", - plainTextSuffix = "\"" + htmlExpectedTag = "code" ) } @@ -124,9 +122,7 @@ class MarkdownParserTest : InstrumentedTest { testType( name = "code", markdownPattern = "``", - htmlExpectedTag = "code", - plainTextPrefix = "\"", - plainTextSuffix = "\"" + htmlExpectedTag = "code" ) } @@ -135,9 +131,7 @@ class MarkdownParserTest : InstrumentedTest { testType( name = "code", markdownPattern = "```", - htmlExpectedTag = "code", - plainTextPrefix = "\"", - plainTextSuffix = "\"" + htmlExpectedTag = "code" ) } @@ -155,58 +149,58 @@ class MarkdownParserTest : InstrumentedTest { @Test fun parseHorizontalLine() { - "---".let { markdownParser.parse(it) }.expect("***", "
b
") + "a\n---\nb".let { markdownParser.parse(it).expect(it, "b
") } } @Test fun parseQuote() { - "> quoted".let { markdownParser.parse(it) }.expect("«quoted»", "") + "> quoted".let { markdownParser.parse(it).expect(it, "quoted
") } } @Test fun parseQuote_not_passing() { - "> quoted\nline2".let { markdownParser.parse(it) }.expect("«quoted\nline2»", "quoted
") + "> quoted\nline2".let { markdownParser.parse(it).expect(it, "quoted
line2
") } } @Test fun parseBoldItalic() { - "*italic* **bold**".let { markdownParser.parse(it) }.expect("italic bold", "italic bold") - "**bold** *italic*".let { markdownParser.parse(it) }.expect("bold italic", "bold italic") + "*italic* **bold**".let { markdownParser.parse(it).expect(it, "italic bold") } + "**bold** *italic*".let { markdownParser.parse(it).expect(it, "bold italic") } } @Test fun parseHead() { - "# head1".let { markdownParser.parse(it) }.expect("head1", "quoted
line2
content
") + "# head\ncontent".let { markdownParser.parse(it).expect(it, "content
") } } private fun testIdentity(text: String) { @@ -215,59 +209,73 @@ class MarkdownParserTest : InstrumentedTest { private fun testType(name: String, markdownPattern: String, - htmlExpectedTag: String, - plainTextPrefix: String = "", - plainTextSuffix: String = "") { + htmlExpectedTag: String) { // Test simple case "$markdownPattern$name$markdownPattern" - .let { markdownParser.parse(it) } - .expect(expectedText = "$plainTextPrefix$name$plainTextSuffix", - expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag>") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag>") + } // Test twice the same tag "$markdownPattern$name$markdownPattern and $markdownPattern$name bis$markdownPattern" - .let { markdownParser.parse(it) } - .expect(expectedText = "$plainTextPrefix$name$plainTextSuffix and $plainTextPrefix$name bis$plainTextSuffix", - expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag> and <$htmlExpectedTag>$name bis$htmlExpectedTag>") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag> and <$htmlExpectedTag>$name bis$htmlExpectedTag>") + } val textBefore = "a" val textAfter = "b" // With sticked text before "$textBefore$markdownPattern$name$markdownPattern" - .let { markdownParser.parse(it) } - .expect(expectedText = "$textBefore$plainTextPrefix$name$plainTextSuffix", - expectedFormattedText = "$textBefore<$htmlExpectedTag>$name$htmlExpectedTag>") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "$textBefore<$htmlExpectedTag>$name$htmlExpectedTag>") + } // With text before and space "$textBefore $markdownPattern$name$markdownPattern" - .let { markdownParser.parse(it) } - .expect(expectedText = "$textBefore $plainTextPrefix$name$plainTextSuffix", - expectedFormattedText = "$textBefore <$htmlExpectedTag>$name$htmlExpectedTag>") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "$textBefore <$htmlExpectedTag>$name$htmlExpectedTag>") + } // With sticked text after "$markdownPattern$name$markdownPattern$textAfter" - .let { markdownParser.parse(it) } - .expect(expectedText = "$plainTextPrefix$name$plainTextSuffix$textAfter", - expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag>$textAfter") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag>$textAfter") + } // With space and text after "$markdownPattern$name$markdownPattern $textAfter" - .let { markdownParser.parse(it) } - .expect(expectedText = "$plainTextPrefix$name$plainTextSuffix $textAfter", - expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag> $textAfter") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "<$htmlExpectedTag>$name$htmlExpectedTag> $textAfter") + } // With sticked text before and text after "$textBefore$markdownPattern$name$markdownPattern$textAfter" - .let { markdownParser.parse(it) } - .expect(expectedText = "$textBefore$plainTextPrefix$name$plainTextSuffix$textAfter", - expectedFormattedText = "a<$htmlExpectedTag>$name$htmlExpectedTag>$textAfter") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "a<$htmlExpectedTag>$name$htmlExpectedTag>$textAfter") + } // With text before and after, with spaces "$textBefore $markdownPattern$name$markdownPattern $textAfter" - .let { markdownParser.parse(it) } - .expect(expectedText = "$textBefore $plainTextPrefix$name$plainTextSuffix $textAfter", - expectedFormattedText = "$textBefore <$htmlExpectedTag>$name$htmlExpectedTag> $textAfter") + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "$textBefore <$htmlExpectedTag>$name$htmlExpectedTag> $textAfter") + } } private fun TextContent.expect(expectedText: String, expectedFormattedText: String?) {