I'm trying to write some unit tests on React + Redux with Jest and Enzyme.
I'm kinda stuck on how I can write unit tests in a conditional rendering container.
...
const {loading} = this.props
if (loading) {
return(
<LoadingModal
//Loading content
/>
)
}
return(<div>//Regular APP</div>)
...
I'm already tested some regular render stuff, but right now I have to test some "loading content"
On my test file, I'm trying to update the store content to {loading: false}
since the reducer initial state is {loading: true}
, but I did not make it.
I'm also using redux-mock-store to try mock the store, as indicated on the following links but no progress was made.
https://github.com/dmitry-zaets/redux-mock-store/issues/85 and Redux How to update the store in unit tests?
my test file looks something like that:
describe('render', ()=>{
beforeEach(()=>{
...
})
it('Loading rendered',()=>{
expect(wrapped.find(LoadingModal).length).toEqual(1)
})
})
If you guys need more information, please let me know,
Thanks in advance.