Fix tests

pull/1826/head
Alex Baker 3 years ago
parent 64a5ea2c69
commit 1de4b220c3

@ -10,6 +10,7 @@ import com.todoroo.astrid.service.TaskDeleter
import com.todoroo.astrid.service.TaskMover import com.todoroo.astrid.service.TaskMover
import com.todoroo.astrid.timers.TimerPlugin import com.todoroo.astrid.timers.TimerPlugin
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.junit.Before import org.junit.Before
import org.tasks.calendars.CalendarEventProvider import org.tasks.calendars.CalendarEventProvider
@ -63,7 +64,10 @@ open class BaseTaskEditViewModelTest : InjectingTestCase() {
db.googleTaskDao, db.googleTaskDao,
db.caldavDao, db.caldavDao,
taskCompleter, taskCompleter,
alarmService) alarmService,
MutableSharedFlow(),
MutableSharedFlow(),
)
} }
protected fun setup(task: Task) = runBlocking { protected fun setup(task: Task) = runBlocking {

@ -319,13 +319,13 @@ class TaskEditViewModel @Inject constructor(
originalAlarms.toHashSet() != selectedAlarms.value.toHashSet() originalAlarms.toHashSet() != selectedAlarms.value.toHashSet()
@MainThread @MainThread
suspend fun save() = withContext(NonCancellable) { suspend fun save(): Boolean = withContext(NonCancellable) {
if (cleared) { if (cleared) {
return@withContext return@withContext false
} }
if (!hasChanges()) { if (!hasChanges()) {
discard() discard()
return@withContext return@withContext false
} }
clear() clear()
task.title = if (title.isNullOrBlank()) context.getString(R.string.no_title) else title task.title = if (title.isNullOrBlank()) context.getString(R.string.no_title) else title
@ -435,6 +435,7 @@ class TaskEditViewModel @Inject constructor(
} }
mainActivityEvents.emit(MainActivityEvent.RequestRating) mainActivityEvents.emit(MainActivityEvent.RequestRating)
} }
true
} }
private suspend fun applyCalendarChanges() { private suspend fun applyCalendarChanges() {

Loading…
Cancel
Save