mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -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()
|
fun atMidnight()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,14 +25,8 @@ class MidnightTimerTest : BaseUnitTest() {
|
|||||||
DateUtils.setFixedLocalTime(unixTime(2017, Calendar.JANUARY, 1, 23, 59, DateUtils.MINUTE_LENGTH - 1))
|
DateUtils.setFixedLocalTime(unixTime(2017, Calendar.JANUARY, 1, 23, 59, DateUtils.MINUTE_LENGTH - 1))
|
||||||
|
|
||||||
val suspendedListener = suspendCoroutine<Boolean> { continuation ->
|
val suspendedListener = suspendCoroutine<Boolean> { continuation ->
|
||||||
val listener = object : MidnightTimer.MidnightListener {
|
|
||||||
override fun atMidnight() {
|
|
||||||
continuation.resume(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MidnightTimer().apply {
|
MidnightTimer().apply {
|
||||||
addListener(listener)
|
addListener { continuation.resume(true) }
|
||||||
// When
|
// When
|
||||||
onResume(1, executor)
|
onResume(1, executor)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user