Presenter testing with Composition Local Providers #2038
matthewbahr-clear
started this conversation in
Ideas
Replies: 1 comment
-
Typically seen this achieved using val presenter = ..
presenterTestOf(
presentFunction = {
withCompositionLocalProvider(..) {
presenter.present()
}
}
) {
awaitItem()
} Might be worth having that in a new |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey wanted to bring up a use case that I ran into recently with an offer building out something more formal if there's interest.
The TLDR is with some small tweaks you can test presenters with composition local providers.
We have an entirely isolated flow (1 public entry screen then everything else is internal) so we added a few contextual fields as composition locals that we didn't want to pipe around from screen to screen.
Since the final presenter ends up interpreting that composable context and then performing an action based on the result of that we needed to be able to provide that field in unit tests.
So I roughed in a pretty basic, small function that allows you to provide composition locals with the caveat that the initial UIState will be null, unlike other current circuit turbines.
Would anyone else find this useful or is this use case too niche to drop into the toolbox?
Beta Was this translation helpful? Give feedback.
All reactions