-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ratings): Fix number of stars shown in VitaminRatings composables (…
- Loading branch information
1 parent
686a6b3
commit 94f29c4
Showing
2 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
ratings/src/test/kotlin/com/decathlon/vitamin/compose/ratings/IconTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.decathlon.vitamin.compose.ratings | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Test | ||
|
||
class IconTest { | ||
@Test | ||
fun integer() { | ||
val number = 3.0f | ||
|
||
assertEquals(Icon.Fill, Icon.get(0, number)) | ||
assertEquals(Icon.Fill, Icon.get(1, number)) | ||
assertEquals(Icon.Fill, Icon.get(2, number)) | ||
assertEquals(Icon.Empty, Icon.get(3, number)) | ||
assertEquals(Icon.Empty, Icon.get(4, number)) | ||
} | ||
|
||
@Test | ||
fun close_above_int() { | ||
val number = 3.2f | ||
|
||
assertEquals(Icon.Fill, Icon.get(0, number)) | ||
assertEquals(Icon.Fill, Icon.get(1, number)) | ||
assertEquals(Icon.Fill, Icon.get(2, number)) | ||
assertEquals(Icon.Empty, Icon.get(3, number)) | ||
assertEquals(Icon.Empty, Icon.get(4, number)) | ||
} | ||
|
||
@Test | ||
fun close_below_half() { | ||
val number = 3.4f | ||
|
||
assertEquals(Icon.Fill, Icon.get(0, number)) | ||
assertEquals(Icon.Fill, Icon.get(1, number)) | ||
assertEquals(Icon.Fill, Icon.get(2, number)) | ||
assertEquals(Icon.Half, Icon.get(3, number)) | ||
assertEquals(Icon.Empty, Icon.get(4, number)) | ||
} | ||
|
||
@Test | ||
fun strictly_half() { | ||
val number = 3.5f | ||
|
||
assertEquals(Icon.Fill, Icon.get(0, number)) | ||
assertEquals(Icon.Fill, Icon.get(1, number)) | ||
assertEquals(Icon.Fill, Icon.get(2, number)) | ||
assertEquals(Icon.Half, Icon.get(3, number)) | ||
assertEquals(Icon.Empty, Icon.get(4, number)) | ||
} | ||
|
||
@Test | ||
fun close_above_half() { | ||
val number = 3.6f | ||
|
||
assertEquals(Icon.Fill, Icon.get(0, number)) | ||
assertEquals(Icon.Fill, Icon.get(1, number)) | ||
assertEquals(Icon.Fill, Icon.get(2, number)) | ||
assertEquals(Icon.Half, Icon.get(3, number)) | ||
assertEquals(Icon.Empty, Icon.get(4, number)) | ||
} | ||
|
||
@Test | ||
fun close_below_int() { | ||
val number = 3.8f | ||
|
||
assertEquals(Icon.Fill, Icon.get(0, number)) | ||
assertEquals(Icon.Fill, Icon.get(1, number)) | ||
assertEquals(Icon.Fill, Icon.get(2, number)) | ||
assertEquals(Icon.Fill, Icon.get(3, number)) | ||
assertEquals(Icon.Empty, Icon.get(4, number)) | ||
} | ||
} |