Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'});
});
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;
});
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;
});