forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix geosolutions-it#1760 update thumbnail with epic
- Loading branch information
Showing
6 changed files
with
94 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
/* | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
var expect = require('expect'); | ||
|
||
const configureMockStore = require('redux-mock-store').default; | ||
const { createEpicMiddleware, combineEpics } = require('redux-observable'); | ||
const {attributeUpdated, ATTRIBUTE_UPDATED} = require('../../actions/maps'); | ||
const {mapsEpic } = require('../maps'); | ||
const rootEpic = combineEpics(mapsEpic); | ||
const epicMiddleware = createEpicMiddleware(rootEpic); | ||
const mockStore = configureMockStore([epicMiddleware]); | ||
|
||
describe('maps Epics', () => { | ||
let store; | ||
beforeEach(() => { | ||
store = mockStore(); | ||
}); | ||
|
||
afterEach(() => { | ||
epicMiddleware.replaceEpic(rootEpic); | ||
}); | ||
|
||
it('produces the maps epic', (done) => { | ||
store.dispatch( attributeUpdated(3, "name", "value", "STRING", "success")); | ||
|
||
setTimeout(() => { | ||
let actions = store.getActions(); | ||
expect(actions.length).toBe(1); | ||
expect(actions[0].type).toBe(ATTRIBUTE_UPDATED); | ||
done(); | ||
}, 400); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const { | ||
ATTRIBUTE_UPDATED, loadMaps, thumbnailError | ||
} = require('../actions/maps'); | ||
|
||
const ConfigUtils = require('../utils/ConfigUtils'); | ||
const Rx = require('rxjs'); | ||
|
||
/** | ||
* Gets every `ATTRIBUTE_UPDATED` event. | ||
* Dispatches the reload of the maps after the attributes are updated | ||
* @param {external:Observable} action$ | ||
* @memberof epics.maps | ||
* @return {external:Observable} | ||
*/ | ||
const mapsEpic = action$ => | ||
action$.ofType(ATTRIBUTE_UPDATED) | ||
.switchMap( () => | ||
Rx.Observable.of(loadMaps(false, ConfigUtils.getDefaults().initialMapFilter || "*")) | ||
.catch(e => Rx.Observable.from([thumbnailError(e)])) | ||
); | ||
|
||
/** | ||
* Actions for maps | ||
* @name epics.maps | ||
*/ | ||
module.exports = { | ||
mapsEpic | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters