From 1de4b220c31393964c3aed90f529d666e688503c Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 21 Mar 2022 22:58:38 -0500 Subject: [PATCH] Fix tests --- .../tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt | 6 +++++- app/src/main/java/org/tasks/ui/TaskEditViewModel.kt | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt index 3c332258f..aed0756a3 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt @@ -10,6 +10,7 @@ import com.todoroo.astrid.service.TaskDeleter import com.todoroo.astrid.service.TaskMover import com.todoroo.astrid.timers.TimerPlugin import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.runBlocking import org.junit.Before import org.tasks.calendars.CalendarEventProvider @@ -63,7 +64,10 @@ open class BaseTaskEditViewModelTest : InjectingTestCase() { db.googleTaskDao, db.caldavDao, taskCompleter, - alarmService) + alarmService, + MutableSharedFlow(), + MutableSharedFlow(), + ) } protected fun setup(task: Task) = runBlocking { diff --git a/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt b/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt index 495d97b39..0fb8707a9 100644 --- a/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt +++ b/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt @@ -319,13 +319,13 @@ class TaskEditViewModel @Inject constructor( originalAlarms.toHashSet() != selectedAlarms.value.toHashSet() @MainThread - suspend fun save() = withContext(NonCancellable) { + suspend fun save(): Boolean = withContext(NonCancellable) { if (cleared) { - return@withContext + return@withContext false } if (!hasChanges()) { discard() - return@withContext + return@withContext false } clear() 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) } + true } private suspend fun applyCalendarChanges() {