updating tests
This commit is contained in:
parent
c6d68b7583
commit
1ed4248e13
|
@ -1,25 +1,38 @@
|
|||
package app.dapk.st.settings
|
||||
|
||||
import app.dapk.st.core.BuildMeta
|
||||
import app.dapk.st.push.PushTokenRegistrars
|
||||
import app.dapk.st.push.Registrar
|
||||
import internalfixture.aSettingHeaderItem
|
||||
import internalfixture.aSettingTextItem
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.junit.Test
|
||||
import test.delegateReturn
|
||||
|
||||
private val A_SELECTION = Registrar("A_SELECTION")
|
||||
|
||||
class SettingsItemFactoryTest {
|
||||
|
||||
private val buildMeta = BuildMeta(versionName = "a-version-name", versionCode = 100)
|
||||
private val fakePushTokenRegistrars = FakePushRegistrars()
|
||||
|
||||
private val settingsItemFactory = SettingsItemFactory(buildMeta, )
|
||||
private val settingsItemFactory = SettingsItemFactory(buildMeta, fakePushTokenRegistrars.instance)
|
||||
|
||||
@Test
|
||||
fun `when creating root items, then is expected`() {
|
||||
fun `when creating root items, then is expected`() = runTest {
|
||||
fakePushTokenRegistrars.givenCurrentSelection().returns(A_SELECTION)
|
||||
|
||||
val result = settingsItemFactory.root()
|
||||
|
||||
result shouldBeEqualTo listOf(
|
||||
aSettingHeaderItem("General"),
|
||||
aSettingTextItem(SettingItem.Id.Encryption, "Encryption"),
|
||||
aSettingTextItem(SettingItem.Id.EventLog, "Event log"),
|
||||
aSettingTextItem(SettingItem.Id.PushProvider, "Push provider", A_SELECTION.id),
|
||||
aSettingHeaderItem("Data"),
|
||||
aSettingTextItem(SettingItem.Id.ClearCache, "Clear cache"),
|
||||
aSettingHeaderItem("Account"),
|
||||
|
@ -29,4 +42,12 @@ class SettingsItemFactoryTest {
|
|||
aSettingTextItem(SettingItem.Id.Ignored, "Version", buildMeta.versionName),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class FakePushRegistrars {
|
||||
|
||||
val instance = mockk<PushTokenRegistrars>()
|
||||
|
||||
fun givenCurrentSelection() = coEvery { instance.currentSelection() }.delegateReturn()
|
||||
|
||||
}
|
|
@ -34,6 +34,7 @@ internal class SettingsViewModelTest {
|
|||
private val fakeCryptoService = FakeCryptoService()
|
||||
private val fakeSyncService = FakeSyncService()
|
||||
private val fakeUriFilenameResolver = FakeUriFilenameResolver()
|
||||
private val fakePushTokenRegistrars = FakePushRegistrars()
|
||||
private val fakeSettingsItemFactory = FakeSettingsItemFactory()
|
||||
|
||||
private val viewModel = SettingsViewModel(
|
||||
|
@ -43,6 +44,7 @@ internal class SettingsViewModelTest {
|
|||
fakeSyncService,
|
||||
fakeUriFilenameResolver.instance,
|
||||
fakeSettingsItemFactory.instance,
|
||||
fakePushTokenRegistrars.instance,
|
||||
runViewModelTest.testMutableStateFactory(),
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package internalfake
|
||||
|
||||
import app.dapk.st.settings.SettingsItemFactory
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import test.delegateReturn
|
||||
|
@ -8,5 +9,5 @@ import test.delegateReturn
|
|||
internal class FakeSettingsItemFactory {
|
||||
val instance = mockk<SettingsItemFactory>()
|
||||
|
||||
fun givenRoot() = every { instance.root() }.delegateReturn()
|
||||
fun givenRoot() = coEvery { instance.root() }.delegateReturn()
|
||||
}
|
Loading…
Reference in New Issue