-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve formatting of day of week ranges
- Loading branch information
Showing
2 changed files
with
126 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
95 changes: 95 additions & 0 deletions
95
app/src/test/java/io/github/janmalch/woroboro/ui/reminder/ReminderListTest.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,95 @@ | ||
package io.github.janmalch.woroboro.ui.reminder | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import java.time.DayOfWeek | ||
import java.util.Locale | ||
|
||
class ReminderListTest { | ||
|
||
private val locale = Locale.GERMAN | ||
|
||
@Test | ||
fun `joinRangesToString should work for a single day`() { | ||
assertEquals( | ||
"Mo.", | ||
setOf(DayOfWeek.MONDAY).joinRangesToString(locale) | ||
) | ||
} | ||
|
||
@Test | ||
fun `joinRangesToString should work for an entire week`() { | ||
assertEquals( | ||
"Mo. β So.", | ||
DayOfWeek.entries.toSet().joinRangesToString(locale) | ||
) | ||
} | ||
|
||
@Test | ||
fun `joinRangesToString should work for every other day`() { | ||
assertEquals( | ||
"Mo., Mi., Fr., So.", | ||
setOf( | ||
DayOfWeek.MONDAY, | ||
DayOfWeek.WEDNESDAY, | ||
DayOfWeek.FRIDAY, | ||
DayOfWeek.SUNDAY | ||
).joinRangesToString(locale) | ||
) | ||
} | ||
|
||
@Test | ||
fun `joinRangesToString should work for a single range`() { | ||
assertEquals( | ||
"Mo. β Fr.", | ||
setOf( | ||
DayOfWeek.MONDAY, | ||
DayOfWeek.TUESDAY, | ||
DayOfWeek.WEDNESDAY, | ||
DayOfWeek.THURSDAY, | ||
DayOfWeek.FRIDAY | ||
).joinRangesToString(locale) | ||
) | ||
} | ||
|
||
@Test | ||
fun `joinRangesToString should work for two ranges`() { | ||
assertEquals( | ||
"Mo. β Mi., Fr. β So.", | ||
setOf( | ||
DayOfWeek.MONDAY, | ||
DayOfWeek.TUESDAY, | ||
DayOfWeek.WEDNESDAY, | ||
DayOfWeek.FRIDAY, | ||
DayOfWeek.SATURDAY, | ||
DayOfWeek.SUNDAY | ||
).joinRangesToString(locale) | ||
) | ||
} | ||
|
||
@Test | ||
fun `joinRangesToString should work for range and single Sunday`() { | ||
assertEquals( | ||
"Mo. β Mi., So.", | ||
setOf( | ||
DayOfWeek.MONDAY, | ||
DayOfWeek.TUESDAY, | ||
DayOfWeek.WEDNESDAY, | ||
DayOfWeek.SUNDAY | ||
).joinRangesToString(locale) | ||
) | ||
} | ||
|
||
@Test | ||
fun `joinRangesToString should work for range and single Saturday`() { | ||
assertEquals( | ||
"Mo. β Mi., Sa.", | ||
setOf( | ||
DayOfWeek.MONDAY, | ||
DayOfWeek.TUESDAY, | ||
DayOfWeek.WEDNESDAY, | ||
DayOfWeek.SATURDAY | ||
).joinRangesToString(locale) | ||
) | ||
} | ||
} |