|
@@ -2,6 +2,7 @@ import fetchMock from 'fetch-mock-jest';
|
|
|
import * as actions from 'redux/actions/actions';
|
|
|
import * as thunks from 'redux/actions/thunks';
|
|
|
import mockStoreCreator from 'redux/store/configureStore/mockStoreCreator';
|
|
|
+import { mockTopicsState } from 'redux/actions/__test__/fixtures';
|
|
|
|
|
|
const store = mockStoreCreator;
|
|
|
|
|
@@ -93,4 +94,42 @@ describe('Thunks', () => {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('fetchTopicConsumerGroups', () => {
|
|
|
+ it('GET_TOPIC_CONSUMER_GROUPS__FAILURE', async () => {
|
|
|
+ fetchMock.getOnce(
|
|
|
+ `api/clusters/${clusterName}/topics/${topicName}/consumergroups`,
|
|
|
+ 404
|
|
|
+ );
|
|
|
+ try {
|
|
|
+ await store.dispatch(
|
|
|
+ thunks.fetchTopicConsumerGroups(clusterName, topicName)
|
|
|
+ );
|
|
|
+ } catch (error) {
|
|
|
+ expect(error.status).toEqual(404);
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.fetchTopicConsumerGroupsAction.request(),
|
|
|
+ actions.fetchTopicConsumerGroupsAction.failure(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('GET_TOPIC_CONSUMER_GROUPS__SUCCESS', async () => {
|
|
|
+ fetchMock.getOnce(
|
|
|
+ `api/clusters/${clusterName}/topics/${topicName}/consumergroups`,
|
|
|
+ 200
|
|
|
+ );
|
|
|
+ try {
|
|
|
+ await store.dispatch(
|
|
|
+ thunks.fetchTopicConsumerGroups(clusterName, topicName)
|
|
|
+ );
|
|
|
+ } catch (error) {
|
|
|
+ expect(error.status).toEqual(200);
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.fetchTopicConsumerGroupsAction.request(),
|
|
|
+ actions.fetchTopicConsumerGroupsAction.success(mockTopicsState),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|