@@ -21,6 +21,11 @@ import org.robolectric.annotation.Config
2121@RunWith(RobolectricTestRunner ::class )
2222class NoteUtilTest : TestCase () {
2323
24+ companion object {
25+ private const val NO_RAW_HTML_TAGS = " Excerpts must not contain raw HTML tags"
26+ private const val TRUNCATED_TO_200 = " Excerpt must be truncated to 200 chars"
27+ }
28+
2429 @Test
2530 fun testIsEmptyLine () {
2631 assertTrue(NoteUtil .isEmptyLine(" " ))
@@ -119,10 +124,10 @@ class NoteUtilTest : TestCase() {
119124 """ .trimIndent()
120125
121126 val excerpt = NoteUtil .generateNoteExcerpt(html, " Title" )
122- assertFalse(" Excerpts must not contain raw HTML tags " , excerpt.contains(" <a " ))
123- assertFalse(" Excerpts must not contain raw HTML tags " , excerpt.contains(" <img" ))
127+ assertFalse(NO_RAW_HTML_TAGS , excerpt.contains(" <a " ))
128+ assertFalse(NO_RAW_HTML_TAGS , excerpt.contains(" <img" ))
124129 assertTrue(" Excerpt should contain visible text content" , excerpt.contains(" click" ))
125- assertTrue(" Excerpt must be truncated to 200 chars " , excerpt.length <= 200 )
130+ assertTrue(TRUNCATED_TO_200 , excerpt.length <= 200 )
126131
127132 assertEquals(excerpt, NoteUtil .generateNoteExcerpt(html, null ))
128133
@@ -137,15 +142,15 @@ class NoteUtilTest : TestCase() {
137142 // excerpt is always truncated to 200 chars rather than storing the full note content.
138143 val code = " if (a < b && b > c) { List<String> names = new ArrayList<>(); }"
139144 val codeExcerpt = NoteUtil .generateNoteExcerpt(code, " Java Logic" )
140- assertTrue(" Excerpt must be truncated to 200 chars " , codeExcerpt.length <= 200 )
145+ assertTrue(TRUNCATED_TO_200 , codeExcerpt.length <= 200 )
141146
142147 val uncompletedHtml = " <div><p>This note is never closed"
143148 assertTrue(NoteUtil .generateNoteExcerpt(uncompletedHtml, null ).contains(" This note is never closed" ))
144149
145150 val longHtml = " <div><p>Very long content that should be shortened eventually...</p></div>"
146151 val longExcerpt = NoteUtil .generateNoteExcerpt(longHtml, " Long Note" )
147152 assertFalse(longExcerpt.endsWith(" <" ))
148- assertTrue(" Excerpt must be truncated to 200 chars " , longExcerpt.length <= 200 )
153+ assertTrue(TRUNCATED_TO_200 , longExcerpt.length <= 200 )
149154 }
150155
151156 private fun testRealisticUserNotes () {
@@ -240,9 +245,9 @@ class NoteUtilTest : TestCase() {
240245 """ .trimIndent()
241246
242247 val clippingExcerpt = NoteUtil .generateNoteExcerpt(webClipping, " Sleep Tips" )
243- assertFalse(" Excerpts must not contain raw HTML tags " , clippingExcerpt.contains(" <h1>" ))
248+ assertFalse(NO_RAW_HTML_TAGS , clippingExcerpt.contains(" <h1>" ))
244249 assertTrue(" Excerpt should contain visible text content" , clippingExcerpt.contains(" quality sleep" ))
245- assertTrue(" Excerpt must be truncated to 200 chars " , clippingExcerpt.length <= 200 )
250+ assertTrue(TRUNCATED_TO_200 , clippingExcerpt.length <= 200 )
246251 }
247252
248253 private fun testTravelPlanNote () {
0 commit comments