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