Skip to content

Commit

Permalink
fix maps getMapsResourcesByCategoryEpic epic wrapper (#5039)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlt1 authored Mar 20, 2020
1 parent 40634df commit 9c1ecf9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion web/client/epics/__tests__/maps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const configureMockStore = require('redux-mock-store').default;
const {createEpicMiddleware, combineEpics } = require('redux-observable');
const {CALL_HISTORY_METHOD} = require('connected-react-router');
const {
saveDetails, SET_DETAILS_CHANGED, MAPS_LIST_LOADING, MAPS_LIST_LOADED,
saveDetails, SET_DETAILS_CHANGED, MAPS_LIST_LOADING, MAPS_LIST_LOADED, MAPS_LIST_LOAD_ERROR,
CLOSE_DETAILS_PANEL, closeDetailsPanel, loadMaps, MAPS_GET_MAP_RESOURCES_BY_CATEGORY,
openDetailsPanel, UPDATE_DETAILS, DETAILS_LOADED, getMapResourcesByCategory,
MAP_DELETING, MAP_DELETED, deleteMap, mapDeleted, TOGGLE_DETAILS_SHEET,
Expand Down Expand Up @@ -653,6 +653,25 @@ describe('Get Map Resource By Category Epic', () => {
});
}))
);
it('test getMapsResourcesByCategoryEpic with an error', (done) => {
const mock = new MockAdapter(axios);
mock.onPost().reply(404);
testEpic(addTimeoutEpic(getMapsResourcesByCategoryEpic), 3, getMapResourcesByCategory('MAP', 'test', {
baseUrl,
params: { start: 0, limit: 12 }
}), actions => {
expect(actions.length).toBe(3);
expect(actions[0].type).toBe(LOADING);
expect(actions[0].value).toBe(true);
expect(actions[0].name).toBe('loadingMaps');
expect(actions[1].type).toBe(MAPS_LIST_LOAD_ERROR);
expect(actions[2].type).toBe(LOADING);
expect(actions[2].value).toBe(false);
expect(actions[2].name).toBe('loadingMaps');
mock.restore();
done();
});
});
});
const Persistence = require("../../api/persistence");
const Rx = require("rxjs");
Expand Down
2 changes: 1 addition & 1 deletion web/client/epics/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const getMapsResourcesByCategoryEpic = (action$, store) =>
.let(wrapStartStop(
loading(true, 'loadingMaps'),
loading(false, 'loadingMaps'),
e => loadError(e)
e => Rx.Observable.of(loadError(e))
));
});

Expand Down

0 comments on commit 9c1ecf9

Please sign in to comment.