Skip to content

Commit

Permalink
fix tests and improve login reset coord editor
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Jun 28, 2018
1 parent 8be49fc commit 9c8266c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ class AnnotationsEditor extends React.Component {
visible: true,
onClick: () => {
this.setState({removing: this.props.id});
// this.props.onRemove(this.props.id);
}
}, {
glyph: 'download',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,36 @@ describe("test the AnnotationsEditor Panel", () => {
expect(spyEdit.calls.length).toEqual(1);
expect(spyRemove.calls.length).toEqual(0);
});
it('test click remove annotation', () => {
const feature = {
id: "1",
title: 'mytitle',
description: '<span><i>desc</i></span>'
};

const testHandlers = {
onEditHandler: (id) => { return id; },
onRemoveHandler: (id) => { return id; }
};

const spyEdit = expect.spyOn(testHandlers, 'onEditHandler');

const viewer = ReactDOM.render(<AnnotationsEditor {...feature} onEdit={testHandlers.onEditHandler}
onRemove={testHandlers.onRemoveHandler}/>, document.getElementById("container"));
expect(viewer).toExist();

let removeButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "button")[2]);

expect(removeButton).toExist();
TestUtils.Simulate.click(removeButton);

const dialog = document.getElementById("confirm-dialog");
let buttons = document.getElementsByTagName("button");

expect(spyEdit.calls.length).toEqual(0);
expect(dialog).toExist();
expect(buttons.length).toBe(7);
});
it('test click remove geometry', () => {
const feature = {
id: "1",
Expand Down
3 changes: 2 additions & 1 deletion web/client/reducers/__tests__/annotations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,13 @@ describe('Test the annotations reducer', () => {
const {point1, lineString1} = testFeatures;
const featureColl = {
type: "FeatureCollection",
features: [lineString1],
features: [lineString1, point1],
tempFeatures: [lineString1],
properties: { id: '1asdfads' },
style: {}
};
const state = annotations({
featureType: "Point",
editing: featureColl,
selected: point1,
drawing: true,
Expand Down
7 changes: 4 additions & 3 deletions web/client/reducers/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,12 @@ function annotations(state = { validationErrors: {} }, action) {
return set("properties.canEdit", false, f);
}), state);
const newfeatures = newState.editing.features;
const tempFeatures = newState.editing.tempFeatures;
// only for the circles the feature is not being added

const features = !state.unsavedGeometry ? state.editing.tempFeatures :
(newState.featureType !== "Circle" ? state.drawing ? slice(newfeatures, 0, newfeatures.length - 1) : tempFeatures : tempFeatures);
let features = newState.editing.tempFeatures;
if (state.featureType !== "Circle" && state.drawing) {
features = slice(newfeatures, 0, newfeatures.length - 1);
}
return assign({}, newState, {
editing: {
...newState.editing,
Expand Down
2 changes: 1 addition & 1 deletion web/client/selectors/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const {createSelector} = require('reselect');
const {layersSelector} = require('./layers');
const {isMapInfoOpen} = require('./mapInfo');
const {isMapInfoOpen} = require('./mapinfo');
const {head, get} = require('lodash');
const assign = require('object-assign');

Expand Down

0 comments on commit 9c8266c

Please sign in to comment.