|
@@ -188,4 +188,101 @@ describe('Thunks', () => {
|
|
|
]);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('fetchGlobalSchemaCompatibilityLevel', () => {
|
|
|
+ it('calls GET_GLOBAL_SCHEMA_COMPATIBILITY__REQUEST on the fucntion call', () => {
|
|
|
+ store.dispatch(thunks.fetchGlobalSchemaCompatibilityLevel(clusterName));
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.fetchGlobalSchemaCompatibilityLevelAction.request(),
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('calls GET_GLOBAL_SCHEMA_COMPATIBILITY__SUCCESS on a successful API call', async () => {
|
|
|
+ fetchMock.getOnce(`/api/clusters/${clusterName}/schemas/compatibility`, {
|
|
|
+ compatibility: CompatibilityLevelCompatibilityEnum.FORWARD,
|
|
|
+ });
|
|
|
+ await store.dispatch(
|
|
|
+ thunks.fetchGlobalSchemaCompatibilityLevel(clusterName)
|
|
|
+ );
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.fetchGlobalSchemaCompatibilityLevelAction.request(),
|
|
|
+ actions.fetchGlobalSchemaCompatibilityLevelAction.success(
|
|
|
+ CompatibilityLevelCompatibilityEnum.FORWARD
|
|
|
+ ),
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('calls GET_GLOBAL_SCHEMA_COMPATIBILITY__FAILURE on an unsuccessful API call', async () => {
|
|
|
+ fetchMock.getOnce(
|
|
|
+ `/api/clusters/${clusterName}/schemas/compatibility`,
|
|
|
+ 404
|
|
|
+ );
|
|
|
+ try {
|
|
|
+ await store.dispatch(
|
|
|
+ thunks.fetchGlobalSchemaCompatibilityLevel(clusterName)
|
|
|
+ );
|
|
|
+ } catch (error) {
|
|
|
+ expect(error.status).toEqual(404);
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.fetchGlobalSchemaCompatibilityLevelAction.request(),
|
|
|
+ actions.fetchGlobalSchemaCompatibilityLevelAction.failure(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('updateGlobalSchemaCompatibilityLevel', () => {
|
|
|
+ const compatibilityLevel = CompatibilityLevelCompatibilityEnum.FORWARD;
|
|
|
+ it('calls POST_GLOBAL_SCHEMA_COMPATIBILITY__REQUEST on the fucntion call', () => {
|
|
|
+ store.dispatch(
|
|
|
+ thunks.updateGlobalSchemaCompatibilityLevel(
|
|
|
+ clusterName,
|
|
|
+ compatibilityLevel
|
|
|
+ )
|
|
|
+ );
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.updateGlobalSchemaCompatibilityLevelAction.request(),
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('calls POST_GLOBAL_SCHEMA_COMPATIBILITY__SUCCESS on a successful API call', async () => {
|
|
|
+ fetchMock.putOnce(
|
|
|
+ `/api/clusters/${clusterName}/schemas/compatibility`,
|
|
|
+ 200
|
|
|
+ );
|
|
|
+ await store.dispatch(
|
|
|
+ thunks.updateGlobalSchemaCompatibilityLevel(
|
|
|
+ clusterName,
|
|
|
+ compatibilityLevel
|
|
|
+ )
|
|
|
+ );
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.updateGlobalSchemaCompatibilityLevelAction.request(),
|
|
|
+ actions.updateGlobalSchemaCompatibilityLevelAction.success(
|
|
|
+ CompatibilityLevelCompatibilityEnum.FORWARD
|
|
|
+ ),
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('calls POST_GLOBAL_SCHEMA_COMPATIBILITY__FAILURE on an unsuccessful API call', async () => {
|
|
|
+ fetchMock.putOnce(
|
|
|
+ `/api/clusters/${clusterName}/schemas/compatibility`,
|
|
|
+ 404
|
|
|
+ );
|
|
|
+ try {
|
|
|
+ await store.dispatch(
|
|
|
+ thunks.updateGlobalSchemaCompatibilityLevel(
|
|
|
+ clusterName,
|
|
|
+ compatibilityLevel
|
|
|
+ )
|
|
|
+ );
|
|
|
+ } catch (error) {
|
|
|
+ expect(error.status).toEqual(404);
|
|
|
+ expect(store.getActions()).toEqual([
|
|
|
+ actions.updateGlobalSchemaCompatibilityLevelAction.request(),
|
|
|
+ actions.updateGlobalSchemaCompatibilityLevelAction.failure(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|