Skip to content

Commit

Permalink
Fix #3192 setting the default layer as object (#3199)
Browse files Browse the repository at this point in the history
  • Loading branch information
baloola authored and offtherailz committed Sep 28, 2018
1 parent e39348a commit fe50170
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions web/client/reducers/__tests__/layers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const { changeLayerParams } = require('../../actions/layers');

describe('Test the layers reducer', () => {

it('confirms that the default state is an object with "flat" as a property', () => {
let state = layers(undefined, {type: 'UNKNOWN'});
expect(state.flat.length).toBe(0);
});

it('returns original state on unrecognized action', () => {
let state = layers(1, {type: 'UNKNOWN'});
expect(state).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion web/client/reducers/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const moveNode = (groups, node, groupId, newLayers, foreground = true) => {
return LayersUtils.removeEmptyGroups(newGroups);
};

function layers(state = [], action) {
function layers(state = { flat: [] }, action) {
switch (action.type) {
case TOGGLE_CONTROL: {
if (action.control === 'RefreshLayers') {
Expand Down
8 changes: 8 additions & 0 deletions web/client/selectors/__tests__/automapupdate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

const expect = require('expect');
const {getWMSLayers, refreshingLayers} = require('../automapupdate');
const reducer = require('../../reducers/layers');

const state = {
layers: {
Expand Down Expand Up @@ -35,4 +36,11 @@ describe('Test automapupdate selectors', () => {

expect(layers.length).toBe(1);
});

it('getWMSLayers works with initial state', () => {
const emptyState = {
layers: reducer(undefined, { type: "TEST" })
};
expect(getWMSLayers(emptyState).length).toBe(0);
});
});

0 comments on commit fe50170

Please sign in to comment.