Fix failing unit tests due to use of experimental API

Both ComposeMessageViewModelTest and MessageRendererTest were failing
because of issues related to usage of experimental delay method

MAILAND-1647
This commit is contained in:
Marino Meneghel 2021-04-16 17:55:00 +02:00
parent 87d6588708
commit e4dddd2ce0
3 changed files with 5 additions and 6 deletions

View File

@ -43,7 +43,6 @@ import java.io.File
import javax.inject.Inject
import kotlin.math.pow
import kotlin.math.sqrt
import kotlin.time.milliseconds
/**
* A class that will inline the images in the message's body.
@ -82,7 +81,7 @@ internal class MessageRenderer(
imageCompressor.send(embeddedImages)
// Workaround that ignore values for the next half second, since ViewModel is emitting
// too many times
delay(DebounceDelay)
delay(debounceDelayMillis)
}
}
@ -227,7 +226,8 @@ internal class MessageRenderer(
}
companion object {
val DebounceDelay = 500.milliseconds
const val debounceDelayMillis = 500L
}
}

View File

@ -80,7 +80,6 @@ import java.util.UUID
import java.util.concurrent.atomic.AtomicReference
import javax.inject.Inject
import kotlin.collections.set
import kotlin.time.seconds
const val NEW_LINE = "<br>"
const val LESS_THAN = "&lt;"
@ -1269,7 +1268,7 @@ class ComposeMessageViewModel @Inject constructor(
autoSaveJob?.cancel()
autoSaveJob = viewModelScope.launch(dispatchers.Io) {
delay(1.seconds)
delay(1000)
Timber.d("Draft auto save triggered")
setBeforeSaveDraft(false, messageBody)
}

View File

@ -114,7 +114,7 @@ internal class MessageRendererTest : CoroutinesTest {
}
repeat(count) {
images.offer(mockEmbeddedImages)
advanceTimeBy(MessageRenderer.DebounceDelay.toLongMilliseconds())
advanceTimeBy(MessageRenderer.debounceDelayMillis)
}
advanceUntilIdle()
renderedBody.close()