How to use the redux-api-middleware/lib/errors.ApiError function in redux-api-middleware

To help you get started, we’ve selected a few redux-api-middleware examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dremio / dremio-oss / dac / ui / src / utils / apiUtils / apiUtils-spec.js View on Github external
it('throws on error', () => {
      const promise = apiUtils.attachFormSubmitHandlers(Promise.resolve({
        error: true,
        payload: new ApiError(500, 'statusText')
      }));
      return expect(promise).to.be.rejectedWith({_error: 'statusText'});
    });
github dremio / dremio-oss / dac / ui / src / pages / AdminPage / subpages / Support-spec.js View on Github external
it('non-existing', async () => {
      input.value = 'n/a';
      const props = {
        ...commonProps,
        getSetting: sinon.stub().returns(Promise.resolve({ payload: new ApiError('test') }))
      };
      const instance = shallow().instance();
      await instance.addAdvanced(evt);
      expect(Array.from(instance.state.tempShown)).to.eql([]);

      expect(evt.target.reset).to.not.have.been.called;
      expect(minimalProps.addNotification).to.have.been.called;
    });
github dremio / dremio-oss / dac / ui / src / mockApi / mockApi-spec.js View on Github external
it('dispatches request, and failure actions when ok is false', () => {
    action[CALL_MOCK_API].mockResponse = {
      ...action[CALL_MOCK_API].mockResponse,
      ok: false,
      status: 500,
      statusText: 'Internal Server Error'
    };
    const promise = mockApiMiddleware(store)(next)(action);

    expect(store.dispatch.args[0][0]).to.eql({type: 'REQUEST'});

    const ret = expect(promise).to.eventually.eql({
      type: 'FAILURE',
      meta: undefined,
      payload: new ApiError(500, 'Internal Server Error', {response: 'foo'}),
      error: true
    });
    clock.tick(1000);
    return ret;
  });