From 203f4be015c1973c2055eae17d18d88527e0e003 Mon Sep 17 00:00:00 2001 From: Oleg Shuralev Date: Wed, 10 Mar 2021 23:08:04 +0300 Subject: [PATCH] createSchema thunk throws an error for unsuccesfull response --- .../src/redux/actions/__test__/thunks.spec.ts | 18 +++++++++++------- kafka-ui-react-app/src/redux/actions/thunks.ts | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/kafka-ui-react-app/src/redux/actions/__test__/thunks.spec.ts b/kafka-ui-react-app/src/redux/actions/__test__/thunks.spec.ts index 611b8ad174..522b7e1f12 100644 --- a/kafka-ui-react-app/src/redux/actions/__test__/thunks.spec.ts +++ b/kafka-ui-react-app/src/redux/actions/__test__/thunks.spec.ts @@ -124,13 +124,17 @@ describe('Thunks', () => { it('creates POST_SCHEMA__FAILURE when posting new schema', async () => { fetchMock.postOnce(`/api/clusters/${clusterName}/schemas`, 404); - await store.dispatch( - thunks.createSchema(clusterName, fixtures.schemaPayload) - ); - expect(store.getActions()).toEqual([ - actions.createSchemaAction.request(), - actions.createSchemaAction.failure(), - ]); + try { + await store.dispatch( + thunks.createSchema(clusterName, fixtures.schemaPayload) + ); + } catch (error) { + expect(error.status).toEqual(404); + expect(store.getActions()).toEqual([ + actions.createSchemaAction.request(), + actions.createSchemaAction.failure(), + ]); + } }); }); }); diff --git a/kafka-ui-react-app/src/redux/actions/thunks.ts b/kafka-ui-react-app/src/redux/actions/thunks.ts index 31222ebb09..36e1ccaeb0 100644 --- a/kafka-ui-react-app/src/redux/actions/thunks.ts +++ b/kafka-ui-react-app/src/redux/actions/thunks.ts @@ -296,5 +296,6 @@ export const createSchema = ( dispatch(actions.createSchemaAction.success(schema)); } catch (e) { dispatch(actions.createSchemaAction.failure()); + throw e; } };