for a unit test, if an intent calls another intent...
# orbit-mvi
k
for a unit test, if an intent calls another intent, the 2nd intent doesn't seem to get executed. Is this expected? Works fine when. running the app live though...the 2nd intent does get run. 2nd intent was done that way get access to reduce, etc. but was intended to be shared code. Is the proper way to do this to pass the SimpleSyntax context along to the shared code?
m
@kenkyee Yes, this is intended behaviour as defined in the unit test documentation. By default we run in so-called
intent isolation
- only the first intent gets executed. This is to avoid testing “too many things” . You can turn this behaviour off by adding
isolateFlow = false
to your
ContainerHost.test
invocation. As to your last question - it’s possible and can be easily done by making an extension function on
SimpleSyntax
.
k
ahh...that makes sense. the docs weren't totally clear about this: • "Loopbacks i.e. intent A calling intent B probably should say "Prevent loopbacks". I thought that meant that it was possible instead... 🙂 Is an extension function technique preferred or passing a simplesyntax object to the 2nd function? And this also keeps highlighting the naming of SimpleSyntax should be changed...hmm...maybe I need to make a typealias for it? 🙂
hmm..I like passing the context through instead like this:
Copy code
actionContext: SimpleSyntax<TaskScreenState, TaskScreenSideEffect>,
m
up to you @kenkyee 😉 Down to individual preference I suppose. Personally I would use an extension function just to hide away this parameter but as I said - personal preference.
Just my 2 cents 🙂
We’re not really forcing you to do much of anything, which is one of our selling points 🙂
👍 2