Skip to content
Discussion options

You must be logged in to vote

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:

// 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
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CharanPera
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants