Unit test for Binding Reducer #3134
Answered
by
mbrandonw
CharanPera
asked this question in
Q&A
-
Hi, How can i write Unit test for the below reducer
|
Beta Was this translation helpful? Give feedback.
Answered by
mbrandonw
Jun 3, 2024
Replies: 1 comment
-
Hi @CharanPera, before telling you how to write a test for that I would want to recommend that perhaps you do not need the However, having said that, you would test this code like so: // Assuming a 'store = TestStore(…)' has been set up
await store.send(.binding(\.pickerSelection, 1)) {
// Assert on anything that changed
}
await store.receive(\.pickerChanged) {
// Assert on anything that changed
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
CharanPera
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @CharanPera, before telling you how to write a test for that I would want to recommend that perhaps you do not need the
pickerChanged
action. You are sending an action to tell the reducer that something changed, but the.binding(\.pickerSelection)
action is exactly that already. Whatever logic you want to do in.pickerChanged
can just be done in.binding(\.pickerSelection)
.However, having said that, you would test this code like so: