Refactor PO Search test suite to use wrapper option#7737
Conversation
...ipt/packages/document-capture/components/in-person-location-post-office-search-step.spec.tsx
Outdated
Show resolved
Hide resolved
…to simplify test setup
e02ab73 to
879a3b3
Compare
JackRyan1989
left a comment
There was a problem hiding this comment.
This looks great! Thanks for taking care of this Matt. Just one small question but it shouldn't hold up approval/merge.
Tests pass in dev env.
|
|
||
| describe('InPersonLocationStep', () => { | ||
| const wrapper: ComponentType = ({ children }) => ( | ||
| <InPersonContext.Provider value={{ arcgisSearchEnabled: true }}> |
There was a problem hiding this comment.
Why is the ordering of the InPersonContext.Provider and the SWRConfig reversed in the wrapper as opposed to the original code?
There was a problem hiding this comment.
Oooh. Hmm. I don't know! I should've kept the original order, but I don't believe order hierarchy affects anything as far as context/providers go (unless there's some promise stuff going on). Unless you have some weird code that is sensitive to timing and re-renders and so on...
There was a problem hiding this comment.
There was a problem hiding this comment.
Yeah, I don't think this is an issue here, but it seems like values could be overwritten:
"The Provider component accepts a value prop to be passed to consuming components that are descendants of this Provider. One Provider can be connected to many consumers. Providers can be nested to override values deeper within the tree." from React Docs.
🛠 Summary of changes
Leverages testing-library's
wrapperoption inrenderto simplify rendering context.