Skip to content

Commit

Permalink
Fix default state of map reducers
Browse files Browse the repository at this point in the history
  • Loading branch information
mwa authored and manisandro committed Dec 12, 2016
1 parent ec9d5a7 commit e60a6a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions web/client/reducers/__tests__/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ describe('Test the map reducer', () => {
expect(state.mapOptions.view).toExist();
expect(state.mapOptions.view.resolutions).toNotExist();
expect(state.mapOptions.view.prop).toBe('prop');

// add map scales with no initial state
state = mapConfig(undefined, action);
expect(state).toExist();
expect(state.mapOptions).toExist();
expect(state.mapOptions.view).toExist();
expect(state.mapOptions.view.resolutions).toExist();
});

it('zoom to extent', () => {
Expand Down
2 changes: 1 addition & 1 deletion web/client/reducers/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var assign = require('object-assign');
var MapUtils = require('../utils/MapUtils');
var CoordinatesUtils = require('../utils/CoordinatesUtils');

function mapConfig(state = null, action) {
function mapConfig(state = {}, action) {
switch (action.type) {
case CHANGE_MAP_VIEW:
const {type, ...params} = action;
Expand Down

0 comments on commit e60a6a5

Please sign in to comment.