mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Simplify midnight timer interface for testing
This commit is contained in:
@@ -57,7 +57,7 @@ open class MidnightTimer @Inject constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
interface MidnightListener {
|
||||
fun interface MidnightListener {
|
||||
fun atMidnight()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,8 @@ class MidnightTimerTest : BaseUnitTest() {
|
||||
DateUtils.setFixedLocalTime(unixTime(2017, Calendar.JANUARY, 1, 23, 59, DateUtils.MINUTE_LENGTH - 1))
|
||||
|
||||
val suspendedListener = suspendCoroutine<Boolean> { continuation ->
|
||||
val listener = object : MidnightTimer.MidnightListener {
|
||||
override fun atMidnight() {
|
||||
continuation.resume(true)
|
||||
}
|
||||
}
|
||||
|
||||
MidnightTimer().apply {
|
||||
addListener(listener)
|
||||
addListener { continuation.resume(true) }
|
||||
// When
|
||||
onResume(1, executor)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user