Skip to content

Commit

Permalink
Fix JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedRejeb committed Mar 31, 2024
1 parent 896e90c commit e70d3b1
Showing 1 changed file with 34 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import kotlin.test.Test
import kotlin.test.assertContains
import kotlin.test.assertEquals

internal class CssDecoderTest {
Expand Down Expand Up @@ -46,8 +47,8 @@ internal class CssDecoderTest {
val color3 = Color(255, 0, 0, 107)
val color4 = Color(0, 0, 255)

assertEquals(
"rgba(255, 0, 0, 1.0)",
assertContains(
listOf("rgba(255, 0, 0, 1.0)", "rgba(255, 0, 0, 1)"),
CssDecoder.decodeColorToCss(color)
)
assertEquals(
Expand All @@ -58,8 +59,8 @@ internal class CssDecoderTest {
"rgba(255, 0, 0, 0.42)",
CssDecoder.decodeColorToCss(color3)
)
assertEquals(
"rgba(0, 0, 255, 1.0)",
assertContains(
listOf("rgba(0, 0, 255, 1.0)", "rgba(0, 0, 255, 1)"),
CssDecoder.decodeColorToCss(color4)
)
}
Expand All @@ -77,12 +78,12 @@ internal class CssDecoderTest {
"12.0px",
CssDecoder.decodeSizeToCss(size)
)
assertEquals(
"16.0px",
assertContains(
listOf("16.0px", "16px"),
CssDecoder.decodeSizeToCss(size2)
)
assertEquals(
"192.0px",
assertContains(
listOf("192.0px", "192px"),
CssDecoder.decodeSizeToCss(size3)
)
assertEquals(
Expand All @@ -93,8 +94,8 @@ internal class CssDecoderTest {
"12.5px",
CssDecoder.decodeSizeToCss(size5)
)
assertEquals(
"-12.0px",
assertContains(
listOf("-12.0px", "-12px"),
CssDecoder.decodeSizeToCss(size6)
)
}
Expand All @@ -110,16 +111,16 @@ internal class CssDecoderTest {
val textUnit7 = TextUnit.Unspecified
val textUnit8: TextUnit? = null

assertEquals(
"12.0em",
assertContains(
listOf("12.0em", "12em"),
CssDecoder.decodeTextUnitToCss(textUnit)
)
assertEquals(
"16.0em",
assertContains(
listOf("16.0em", "16em"),
CssDecoder.decodeTextUnitToCss(textUnit2)
)
assertEquals(
"192.0em",
assertContains(
listOf("192.0em", "192em"),
CssDecoder.decodeTextUnitToCss(textUnit3)
)
assertEquals(
Expand All @@ -130,8 +131,8 @@ internal class CssDecoderTest {
"12.5em",
CssDecoder.decodeTextUnitToCss(textUnit5)
)
assertEquals(
"24.0px",
assertContains(
listOf("24.0px", "24px"),
CssDecoder.decodeTextUnitToCss(textUnit6)
)
assertEquals(
Expand Down Expand Up @@ -282,16 +283,25 @@ internal class CssDecoderTest {
color = Color(255, 204, 0)
)

assertEquals(
"1.0px 1.0px 1.0px rgba(0, 0, 0, 1.0)",
assertContains(
listOf(
"1.0px 1.0px 1.0px rgba(0, 0, 0, 1.0)",
"1px 1px 1px rgba(0, 0, 0, 1)"
),
CssDecoder.decodeTextShadowToCss(textShadow)
)
assertEquals(
"1.0px 1.0px 2.0px rgba(0, 0, 0, 1.0)",
assertContains(
listOf(
"1.0px 1.0px 2.0px rgba(0, 0, 0, 1.0)",
"1px 1px 2px rgba(0, 0, 0, 1)"
),
CssDecoder.decodeTextShadowToCss(textShadow2)
)
assertEquals(
"1.0px 1.0px 2.0px rgba(255, 204, 0, 1.0)",
assertContains(
listOf(
"1.0px 1.0px 2.0px rgba(255, 204, 0, 1.0)",
"1px 1px 2px rgba(255, 204, 0, 1)"
),
CssDecoder.decodeTextShadowToCss(textShadow3)
)
}
Expand Down

0 comments on commit e70d3b1

Please sign in to comment.