From cd6857eb8d89b9f5e470cefa33b343c508b7e180 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 1 Nov 2022 18:01:39 +0000 Subject: [PATCH] add initial state test --- .../gallery/state/ImageGalleryReducerTest.kt | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt diff --git a/features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt b/features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt new file mode 100644 index 0000000..e6e8aac --- /dev/null +++ b/features/messenger/src/test/kotlin/app/dapk/st/messenger/gallery/state/ImageGalleryReducerTest.kt @@ -0,0 +1,54 @@ +package app.dapk.st.messenger.gallery.state + +import app.dapk.st.core.Lce +import app.dapk.st.design.components.SpiderPage +import app.dapk.st.messenger.gallery.FetchMediaFoldersUseCase +import app.dapk.st.messenger.gallery.FetchMediaUseCase +import app.dapk.st.messenger.gallery.PageContainer +import app.dapk.state.Combined2 +import fake.FakeJobBag +import io.mockk.mockk +import org.junit.Test +import test.testReducer + +private const val A_ROOM_NAME = "a room name" + +class ImageGalleryReducerTest { + + private val fakeJobBag = FakeJobBag() + + private val runReducerTest = testReducer { _: (Unit) -> Unit -> + imageGalleryReducer( + A_ROOM_NAME, + FakeFetchMediaFoldersUseCase().instance, + FakeFetchMediaUseCase().instance, + fakeJobBag.instance, + ) + } + + @Test + fun `initial state is folders page`() = runReducerTest { + assertInitialState( + Combined2( + state1 = PageContainer( + SpiderPage( + route = ImageGalleryPage.Routes.folders, + label = "Send to $A_ROOM_NAME", + parent = null, + state = ImageGalleryPage.Folders(Lce.Loading()) + ) + ), + state2 = Unit + ) + ) + } + +} + +class FakeFetchMediaFoldersUseCase { + val instance = mockk() +} + +class FakeFetchMediaUseCase { + val instance = mockk() +} \ No newline at end of file