Loading app/src/main/java/foundation/e/apps/data/application/utils/CategoryStringFormatter.kt +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ object CategoryStringFormatter { "unknown" -> "Unknown" else -> input.replace("_", " ").split(" ").joinToString(" ") { word -> if (word.lowercase() == "and") word if (word.lowercase() == "and") word.lowercase(Locale.getDefault()) else { word.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) Loading app/src/test/java/foundation/e/apps/category/CategoryStringFormatterTest.kt +19 −3 Original line number Diff line number Diff line Loading @@ -33,9 +33,17 @@ class CategoryStringFormatterTest { } @Test fun testFormatString_withMultipleWords() { val input = "mental_health_and_fitness" val expected = "Mental Health and Fitness" fun testFormatString_withSpaces() { val input = "health and fitness" val expected = "Health and Fitness" val result = CategoryStringFormatter.format(input) assertEquals(expected, result) } @Test fun testFormatString_withAllWordsCapitalized() { val input = "Health And Fitness" val expected = "Health and Fitness" val result = CategoryStringFormatter.format(input) assertEquals(expected, result) } Loading Loading @@ -65,6 +73,14 @@ class CategoryStringFormatterTest { assertEquals(expected, result) } @Test fun testFormatString_withOnlyCapitalizedAnd() { val input = "And" val expected = "and" val result = CategoryStringFormatter.format(input) assertEquals(expected, result) } @Test fun testFormatString_withEmptyString() { val input = "" Loading Loading
app/src/main/java/foundation/e/apps/data/application/utils/CategoryStringFormatter.kt +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ object CategoryStringFormatter { "unknown" -> "Unknown" else -> input.replace("_", " ").split(" ").joinToString(" ") { word -> if (word.lowercase() == "and") word if (word.lowercase() == "and") word.lowercase(Locale.getDefault()) else { word.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) Loading
app/src/test/java/foundation/e/apps/category/CategoryStringFormatterTest.kt +19 −3 Original line number Diff line number Diff line Loading @@ -33,9 +33,17 @@ class CategoryStringFormatterTest { } @Test fun testFormatString_withMultipleWords() { val input = "mental_health_and_fitness" val expected = "Mental Health and Fitness" fun testFormatString_withSpaces() { val input = "health and fitness" val expected = "Health and Fitness" val result = CategoryStringFormatter.format(input) assertEquals(expected, result) } @Test fun testFormatString_withAllWordsCapitalized() { val input = "Health And Fitness" val expected = "Health and Fitness" val result = CategoryStringFormatter.format(input) assertEquals(expected, result) } Loading Loading @@ -65,6 +73,14 @@ class CategoryStringFormatterTest { assertEquals(expected, result) } @Test fun testFormatString_withOnlyCapitalizedAnd() { val input = "And" val expected = "and" val result = CategoryStringFormatter.format(input) assertEquals(expected, result) } @Test fun testFormatString_withEmptyString() { val input = "" Loading