瀏覽代碼

createSchema thunk throws an error for unsuccesfull response

Oleg Shuralev 4 年之前
父節點
當前提交
203f4be015

+ 11 - 7
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(),
+        ]);
+      }
     });
   });
 });

+ 1 - 0
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;
   }
 };