Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anty0 committed Dec 2, 2024
1 parent c92469b commit d8d61b1
Showing 1 changed file with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,50 @@ class PoToICUConverterTest {
)
}

@Test
fun testPhpPluralsWithHashtags() {
val result =
getPhpConvertor().convert(
rawData =
mapOf(
0 to "Petr má jeden znak #.",
1 to "Petr má %d znaky #.",
2 to "Petr má %d znaků #.",
),
languageTag = "cs",
convertPlaceholders = true,
).message
assertThat(result).isEqualTo(
"{0, plural,\n" +
"one {Petr má jeden znak '#'.}\n" +
"few {Petr má # znaky '#'.}\n" +
"other {Petr má # znaků '#'.}\n" +
"}",
)
}

@Test
fun testPhpPluralsWithHashtagsAndDisabledPlaceholders() {
val result =
getPhpConvertor().convert(
rawData =
mapOf(
0 to "Petr má jeden znak #.",
1 to "Petr má %d znaky #.",
2 to "Petr má %d znaků #.",
),
languageTag = "cs",
convertPlaceholders = false,
).message
assertThat(result).isEqualTo(
"{value, plural,\n" +
"one {Petr má jeden znak '#'.}\n" +
"few {Petr má %d znaky '#'.}\n" +
"other {Petr má %d znaků '#'.}\n" +
"}",
)
}

private fun getPhpConvertor() = PoToIcuMessageConvertor { PhpToIcuPlaceholderConvertor() }

@Test
Expand All @@ -48,6 +92,20 @@ class PoToICUConverterTest {
assertThat(result).isEqualTo("hello this is string {0}, this is digit {1, number}")
}

@Test
fun testPhpMessageWithHashtag() {
val result =
getPhpConvertor().convert("hello this is hashtag # and it should not be escaped", "en").message
assertThat(result).isEqualTo("hello this is hashtag # and it should not be escaped")
}

@Test
fun testPhpMessageWithHashtagAndDisabledPlaceholders() {
val result =
getPhpConvertor().convert("hello this is hashtag # and it should not be escaped", "en", convertPlaceholders = false).message
assertThat(result).isEqualTo("hello this is hashtag # and it should not be escaped")
}

@Test
fun testPhpMessageEscapes() {
val result =
Expand Down

0 comments on commit d8d61b1

Please sign in to comment.