adding test for cancelling previous page job
- fixes wrong page key being used to cancel previous
This commit is contained in:
parent
6492afe063
commit
b1c5481d1e
|
@ -57,7 +57,7 @@ fun imageGalleryReducer(
|
|||
},
|
||||
|
||||
sideEffect(PageStateChange.ChangePage::class) { action, _ ->
|
||||
jobBag.cancel(action.previous::class)
|
||||
jobBag.cancel(action.previous.state::class)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -90,6 +90,14 @@ class ImageGalleryReducerTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when ChangePage, then cancels previous page jobs`() = runReducerTest {
|
||||
fakeJobBag.instance.expect { it.cancel(ImageGalleryPage.Folders::class) }
|
||||
|
||||
reduce(PageStateChange.ChangePage(previous = AN_INITIAL_FOLDERS_PAGE, newPage = AN_INITIAL_FILES_PAGE))
|
||||
|
||||
assertOnlyStateChange(pageState(AN_INITIAL_FILES_PAGE))
|
||||
}
|
||||
}
|
||||
|
||||
private fun <P> pageState(page: SpiderPage<out P>) = Combined2(PageContainer(page), Unit)
|
||||
|
|
Loading…
Reference in New Issue