Skip to content

Commit 6643274

Browse files
committed
Add unit tests
1 parent c083859 commit 6643274

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

aztec/src/test/kotlin/org/wordpress/aztec/CalypsoFormattingTest.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ class CalypsoFormattingTest : AndroidTestCase() {
7676
"<div class=\"fourth\"><u>Under</u>line</div>\n" +
7777
"<div class=\"fifth\"></div>\n</div>\n</div>"
7878

79+
private val HTML_MIXED_REGEX =
80+
"\n\n<span><i>Italic</i></span>\n\n<b>Bold</b><br>" +
81+
"\t<div class=\"\$\$\$first\">" +
82+
"<a href=\"https://github.com/wordpress-mobile/Word\\Press-Aztec-Android\">Link</a>" +
83+
" \t<div class=\"sec $8 ond\"></div></div>"
84+
85+
private val HTML_MIXED_REGEX_CALYPSO =
86+
"<span><i>Italic</i></span>\n\n<b>Bold</b>\n" +
87+
"<div class=\"\$\$\$first\">" +
88+
"<a href=\"https://github.com/wordpress-mobile/Word\\Press-Aztec-Android\">Link</a>\n" +
89+
"<div class=\"sec $8 ond\"></div>\n" +
90+
"</div>"
91+
7992
/**
8093
* Initialize variables.
8194
*/
@@ -125,4 +138,18 @@ class CalypsoFormattingTest : AndroidTestCase() {
125138
val output = Format.addSourceEditorFormatting(parser.toHtml(span), true)
126139
Assert.assertEquals(HTML_MIXED_WITH_NEWLINES_CALYPSO, output)
127140
}
141+
142+
/**
143+
* Test the conversion of HTML containing special regex characters
144+
*
145+
* @throws Exception
146+
*/
147+
@Test
148+
@Throws(Exception::class)
149+
fun formatRegexSpecialCharactersCalypso() {
150+
val input = Format.removeSourceEditorFormatting(HTML_MIXED_REGEX, true)
151+
val span = SpannableString(parser.fromHtml(input, context))
152+
val output = Format.addSourceEditorFormatting(parser.toHtml(span), true)
153+
Assert.assertEquals(HTML_MIXED_REGEX_CALYPSO, output)
154+
}
128155
}

0 commit comments

Comments
 (0)