Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can moxios catch request from click event? #56

Closed
z2014 opened this issue Dec 14, 2018 · 1 comment
Closed

can moxios catch request from click event? #56

z2014 opened this issue Dec 14, 2018 · 1 comment

Comments

@z2014
Copy link

z2014 commented Dec 14, 2018

when i use redux, and i click a button, call a action, in action, a instance of axios was called, code like this

beforeEach(() => {
    moxios.install(instance);
    store = configureStore(initialStore)
    wrapper = Enzyme.mount(
        <Provider store={store}>
            <AppInput onChange={updateAppInfo}/>
        </Provider>
    )
})
it('updateAppInfo', (done) => {
        moxios.stubRequest('/app/get', {
            status: 200,
            responseText: 'hello'
        })
        wrapper.find('.xj-appinput-item').at(0).simulate('click');
        
        moxios.wait(() => {
            let request = moxios.requests.mostRecent();
            request.respondWith({
                status: 200,
                response: { a: 22 }
            }).then(() => {
            });
        });
    })

updateAppInfo function send a request which url is /app/get,
and as expect, moxios will catch this request,
but i got this error,
TypeError: Cannot read property 'respondWith' of undefined
so i wonder how to fix this?

@z2014 z2014 changed the title can can moxios catch request from click event? Dec 14, 2018
@z2014
Copy link
Author

z2014 commented Dec 14, 2018

ok,i got it.you should call dispatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants