Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add tests for theme repository #182

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ class DefaultThemeRepositoryTest {
assertEquals(UiFontFamily.NotoSans, resAfter)
}

@Test
fun whenChangeUiFontScale_thenValueIsAsExpected() {
val resBefore = sut.uiFontScale.value
assertEquals(1f, resBefore)

val value = 1.5f
sut.changeUiFontScale(value)

val resAfter = sut.uiFontScale.value
assertEquals(value, resAfter)
}

@Test
fun whenChangeContentFontScales_thenValueIsAsExpected() {
val resBefore = sut.contentFontScale.value
Expand Down Expand Up @@ -103,6 +115,38 @@ class DefaultThemeRepositoryTest {
assertEquals(Color.Red, resAfter)
}

@Test
fun whenChangeUpVoteColor_thenValueIsAsExpected() {
sut.changeUpVoteColor(Color.Red)

val resAfter = sut.upVoteColor.value
assertEquals(Color.Red, resAfter)
}

@Test
fun whenChangeDownVoteColor_thenValueIsAsExpected() {
sut.changeDownVoteColor(Color.Red)

val resAfter = sut.downVoteColor.value
assertEquals(Color.Red, resAfter)
}

@Test
fun whenChangeReplyColor_thenValueIsAsExpected() {
sut.changeReplyColor(Color.Red)

val resAfter = sut.replyColor.value
assertEquals(Color.Red, resAfter)
}

@Test
fun whenChangeSaveColor_thenValueIsAsExpected() {
sut.changeSaveColor(Color.Red)

val resAfter = sut.saveColor.value
assertEquals(Color.Red, resAfter)
}

@Test
fun whenChangeCommentBarTheme_thenValueIsAsExpected() {
val resBefore = sut.commentBarTheme.value
Expand All @@ -113,4 +157,80 @@ class DefaultThemeRepositoryTest {
val resAfter = sut.commentBarTheme.value
assertEquals(CommentBarTheme.Green, resAfter)
}

@Test
fun getCommentBarColorGreen_thenValueIsAsExpected() {
val res0 = sut.getCommentBarColor(0, CommentBarTheme.Green)
val res1 = sut.getCommentBarColor(1, CommentBarTheme.Green)
val res2 = sut.getCommentBarColor(2, CommentBarTheme.Green)
val res3 = sut.getCommentBarColor(3, CommentBarTheme.Green)
val res4 = sut.getCommentBarColor(4, CommentBarTheme.Green)
val res5 = sut.getCommentBarColor(5, CommentBarTheme.Green)
val res6 = sut.getCommentBarColor(6, CommentBarTheme.Green)

assertEquals(Color(0xFF1B4332), res0)
assertEquals(Color(0xFF2D6A4F), res1)
assertEquals(Color(0xFF40916C), res2)
assertEquals(Color(0xFF52B788), res3)
assertEquals(Color(0xFF74C69D), res4)
assertEquals(Color(0xFF95D5B2), res5)
assertEquals(Color(0xFF1B4332), res6)
}

@Test
fun getCommentBarColorRed_thenValueIsAsExpected() {
val res0 = sut.getCommentBarColor(0, CommentBarTheme.Red)
val res1 = sut.getCommentBarColor(1, CommentBarTheme.Red)
val res2 = sut.getCommentBarColor(2, CommentBarTheme.Red)
val res3 = sut.getCommentBarColor(3, CommentBarTheme.Red)
val res4 = sut.getCommentBarColor(4, CommentBarTheme.Red)
val res5 = sut.getCommentBarColor(5, CommentBarTheme.Red)
val res6 = sut.getCommentBarColor(6, CommentBarTheme.Red)

assertEquals(Color(0xFF6A040F), res0)
assertEquals(Color(0xFF9D0208), res1)
assertEquals(Color(0xFFD00000), res2)
assertEquals(Color(0xFFDC2F02), res3)
assertEquals(Color(0xFFE85D04), res4)
assertEquals(Color(0xFFF48C06), res5)
assertEquals(Color(0xFF6A040F), res6)
}

@Test
fun getCommentBarColorBlue_thenValueIsAsExpected() {
val res0 = sut.getCommentBarColor(0, CommentBarTheme.Blue)
val res1 = sut.getCommentBarColor(1, CommentBarTheme.Blue)
val res2 = sut.getCommentBarColor(2, CommentBarTheme.Blue)
val res3 = sut.getCommentBarColor(3, CommentBarTheme.Blue)
val res4 = sut.getCommentBarColor(4, CommentBarTheme.Blue)
val res5 = sut.getCommentBarColor(5, CommentBarTheme.Blue)
val res6 = sut.getCommentBarColor(6, CommentBarTheme.Blue)

assertEquals(Color(0xFF012A4A), res0)
assertEquals(Color(0xFF013A63), res1)
assertEquals(Color(0xFF014F86), res2)
assertEquals(Color(0xFF2C7DA0), res3)
assertEquals(Color(0xFF61A5C2), res4)
assertEquals(Color(0xFFA9D6E5), res5)
assertEquals(Color(0xFF012A4A), res6)
}

@Test
fun getCommentBarColorRainbow_thenValueIsAsExpected() {
val res0 = sut.getCommentBarColor(0, CommentBarTheme.Rainbow)
val res1 = sut.getCommentBarColor(1, CommentBarTheme.Rainbow)
val res2 = sut.getCommentBarColor(2, CommentBarTheme.Rainbow)
val res3 = sut.getCommentBarColor(3, CommentBarTheme.Rainbow)
val res4 = sut.getCommentBarColor(4, CommentBarTheme.Rainbow)
val res5 = sut.getCommentBarColor(5, CommentBarTheme.Rainbow)
val res6 = sut.getCommentBarColor(6, CommentBarTheme.Rainbow)

assertEquals(Color(0xFF9400D3), res0)
assertEquals(Color(0xFF0000FF), res1)
assertEquals(Color(0xFF00FF00), res2)
assertEquals(Color(0xFFFFFF00), res3)
assertEquals(Color(0xFFFF7F00), res4)
assertEquals(Color(0xFFFF0000), res5)
assertEquals(Color(0xFF9400D3), res6)
}
}
Loading