diff --git a/chat-engine/src/testFixtures/kotlin/fake/FakeChatEngine.kt b/chat-engine/src/testFixtures/kotlin/fake/FakeChatEngine.kt index 823bc26..8028923 100644 --- a/chat-engine/src/testFixtures/kotlin/fake/FakeChatEngine.kt +++ b/chat-engine/src/testFixtures/kotlin/fake/FakeChatEngine.kt @@ -2,9 +2,11 @@ package fake import app.dapk.st.engine.ChatEngine import app.dapk.st.matrix.common.RoomId +import io.mockk.coEvery import io.mockk.every import io.mockk.mockk import test.delegateReturn +import java.io.InputStream class FakeChatEngine : ChatEngine by mockk() { @@ -12,4 +14,6 @@ class FakeChatEngine : ChatEngine by mockk() { fun givenDirectory() = every { directory() }.delegateReturn() + fun givenImportKeys(inputStream: InputStream, passphrase: String) = coEvery { inputStream.importRoomKeys(passphrase) }.delegateReturn() + } \ No newline at end of file diff --git a/features/settings/build.gradle b/features/settings/build.gradle index fc553d4..7eb18c8 100644 --- a/features/settings/build.gradle +++ b/features/settings/build.gradle @@ -12,11 +12,10 @@ dependencies { kotlinTest(it) - androidImportFixturesWorkaround(project, project(":matrix:services:sync")) - androidImportFixturesWorkaround(project, project(":matrix:services:crypto")) androidImportFixturesWorkaround(project, project(":matrix:common")) androidImportFixturesWorkaround(project, project(":core")) androidImportFixturesWorkaround(project, project(":domains:store")) androidImportFixturesWorkaround(project, project(":domains:android:viewmodel")) androidImportFixturesWorkaround(project, project(":domains:android:stub")) + androidImportFixturesWorkaround(project, project(":chat-engine")) } \ No newline at end of file diff --git a/features/settings/src/test/kotlin/app/dapk/st/settings/SettingsViewModelTest.kt b/features/settings/src/test/kotlin/app/dapk/st/settings/SettingsViewModelTest.kt index 87477c4..98c4f12 100644 --- a/features/settings/src/test/kotlin/app/dapk/st/settings/SettingsViewModelTest.kt +++ b/features/settings/src/test/kotlin/app/dapk/st/settings/SettingsViewModelTest.kt @@ -3,9 +3,8 @@ package app.dapk.st.settings import ViewModelTest import app.dapk.st.core.Lce import app.dapk.st.design.components.SpiderPage -import app.dapk.st.matrix.crypto.ImportResult +import app.dapk.st.engine.ImportResult import fake.* -import fake.FakeStoreCleaner import fixture.aRoomId import internalfake.FakeSettingsItemFactory import internalfake.FakeUriFilenameResolver @@ -35,20 +34,18 @@ internal class SettingsViewModelTest { private val fakeStoreCleaner = FakeStoreCleaner() private val fakeContentResolver = FakeContentResolver() - private val fakeCryptoService = FakeCryptoService() - private val fakeSyncService = FakeSyncService() private val fakeUriFilenameResolver = FakeUriFilenameResolver() private val fakePushTokenRegistrars = FakePushRegistrars() private val fakeSettingsItemFactory = FakeSettingsItemFactory() private val fakeThemeStore = FakeThemeStore() private val fakeLoggingStore = FakeLoggingStore() private val fakeMessageOptionsStore = FakeMessageOptionsStore() + private val fakeChatEngine = FakeChatEngine() private val viewModel = SettingsViewModel( + fakeChatEngine, fakeStoreCleaner, fakeContentResolver.instance, - fakeCryptoService, - fakeSyncService, fakeUriFilenameResolver.instance, fakeSettingsItemFactory.instance, fakePushTokenRegistrars.instance, @@ -174,9 +171,8 @@ internal class SettingsViewModelTest { @Test fun `given success when importing room keys, then emits progress`() = runViewModelTest { - fakeSyncService.expectUnit { it.forceManualRefresh(A_LIST_OF_ROOM_IDS) } fakeContentResolver.givenFile(A_URI.instance).returns(AN_INPUT_STREAM.instance) - fakeCryptoService.givenImportKeys(AN_INPUT_STREAM.instance, A_PASSPHRASE).returns(flowOf(AN_IMPORT_SUCCESS)) + fakeChatEngine.givenImportKeys(AN_INPUT_STREAM.instance, A_PASSPHRASE).returns(flowOf(AN_IMPORT_SUCCESS)) viewModel .test(initialState = SettingsScreenState(A_IMPORT_ROOM_KEYS_PAGE_WITH_SELECTION))