Skip to content

Commit

Permalink
Add stack action path element subscript to testing notes (#2704)
Browse files Browse the repository at this point in the history
* Add stack action path element subscript to testing notes

Updates the stack navigation documentation to include information on how to test that a specific element action is received using case key paths.

Wording could maybe be improved but its a starting point.

* Update StackBasedNavigation.md

---------

Co-authored-by: Brandon Williams <[email protected]>
  • Loading branch information
lukeredpath and mbrandonw authored Jan 16, 2024
1 parent 40304a1 commit d1eaa5d
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,18 @@ await store.receive(\.path.popFrom) {
}
```

If you need to assert that a specific child action is received, you can construct a case key path
for a specific child element action by subscripting on the `\.path` case with the element ID.

For example, if the child feature performed an effect that sent an `.response` action, you
can test that it is received:

```swift
await store.receive(\.path[id: 0].counter.response) {
// ...
}
```

This shows how we can write very nuanced tests on how parent and child features interact with each
other in a navigation stack.

Expand Down

0 comments on commit d1eaa5d

Please sign in to comment.