Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mori-atsushi committed Nov 24, 2023
1 parent 4c34446 commit fa5d013
Showing 1 changed file with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.moriatsushi.compose.stylesheet.border

import androidx.compose.foundation.BorderStroke
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.unit.dp
import com.moriatsushi.compose.stylesheet.graphics.BrushStyle
import com.moriatsushi.compose.stylesheet.token.Token
import kotlin.test.Test
import kotlin.test.assertEquals

class BorderSetterTest {
@Test
fun testWidth() {
val setter = BorderSetter()
setter.width += 10.dp
assertEquals(BorderStyle(width = Token(10.dp)), setter.value)
}

@Test
fun testWidth_override() {
val setter = BorderSetter()
setter += BorderStyle(width = Token(10.dp))
setter.width += 20.dp
assertEquals(BorderStyle(width = Token(20.dp)), setter.value)
}

@Test
fun testBrush() {
val setter = BorderSetter()
setter.brush += BrushStyle(Color.Black)
assertEquals(
BorderStyle(brush = Token(BrushStyle(Color.Black))),
setter.value,
)
}

@Test
fun testBrush_override() {
val setter = BorderSetter()
setter += BorderStyle(brush = Token(BrushStyle(Color.Black)))
setter.brush += BrushStyle(Color.Red)
assertEquals(
BorderStyle(brush = Token(BrushStyle(Color.Red))),
setter.value,
)
}

@Test
fun testColor() {
val setter = BorderSetter()
setter.color += Color.Black
assertEquals(
BorderStyle(brush = Token(BrushStyle(Color.Black))),
setter.value,
)
}

@Test
fun testColor_override() {
val setter = BorderSetter()
setter += BorderStyle(brush = Token(BrushStyle(Color.Black)))
setter.color += Color.Red
assertEquals(
BorderStyle(brush = Token(BrushStyle(Color.Red))),
setter.value,
)
}

@Test
fun testBorderStyle() {
val setter = BorderSetter()
setter += BorderStroke(1.dp, Color.Black)
assertEquals(
BorderStyle(width = Token(1.dp), brush = Token(BrushStyle(SolidColor(Color.Black)))),
setter.value,
)
}
}

0 comments on commit fa5d013

Please sign in to comment.