score:0

i overrode the responses jwt with my own token of "123". i don't know if this is correct though, nor do i ever expect a response to this post.

const middleware = [thunk];
const mockstore = configuremockstore(middleware);

describe('redux async actions', () => {
  aftereach(() => {
    fetchmock.reset();
    fetchmock.restore();
  });

  it('returns expected login response', async () => {
    const expectedactions = {
      payload: { token: '123' },
      type: 'login_success',
    };

    const store = mockstore({ alert: [], auth: { token: '123' } });

    return store
      .dispatch(actions.login('user@gmail.com', 'somepassword'))
      .then(() => {
        // return of async actions
        const actionsresponse = store.getactions();
        actionsresponse[0].payload.token = '123';
        expect(actionsresponse[0]).toequal(expectedactions);
      });
  });
});

Related Query

More Query from same tag