Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annotations updates for Openlayers #2612

Merged
merged 3 commits into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 70 additions & 7 deletions web/client/actions/__tests__/annotations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ const {
HIGHLIGHT,
CLEAN_HIGHLIGHT,
FILTER_ANNOTATIONS,
showTextArea, SHOW_TEXT_AREA,
addText, ADD_TEXT,
cancelText, CANCEL_CLOSE_TEXT,
changedProperties, CHANGED_PROPERTIES,
changeStyler, CHANGE_STYLER,
saveText, SAVE_TEXT,
toggleUnsavedStyleModal, TOGGLE_STYLE_MODAL,
stopDrawing, STOP_DRAWING,
toggleUnsavedChangesModal, TOGGLE_CHANGES_MODAL,
setUnsavedStyle, UNSAVED_STYLE,
setUnsavedChanges, UNSAVED_CHANGES,
editAnnotation,
removeAnnotation,
confirmRemoveAnnotation,
Expand All @@ -58,7 +69,7 @@ const {

describe('Test correctness of the annotations actions', () => {
it('edit annotation', (done) => {
const result = editAnnotation('1', 'Point');
const result = editAnnotation('1');
expect(result).toExist();
expect(isFunction(result)).toBe(true);
result((action) => {
Expand All @@ -75,6 +86,9 @@ describe('Test correctness of the annotations actions', () => {
properties: {
id: '1',
name: 'myannotation'
},
geometry: {
type: "Point"
}
}]
}]
Expand All @@ -87,23 +101,73 @@ describe('Test correctness of the annotations actions', () => {
expect(result.type).toEqual(REMOVE_ANNOTATION);
expect(result.id).toEqual('1');
});

it('showTextArea', () => {
const result = showTextArea();
expect(result.type).toEqual(SHOW_TEXT_AREA);
});
it('addText', () => {
const result = addText();
expect(result.type).toEqual(ADD_TEXT);
});
it('cancelText', () => {
const result = cancelText();
expect(result.type).toEqual(CANCEL_CLOSE_TEXT);
});
it('confirm remove annotation', () => {
const result = confirmRemoveAnnotation('1');
expect(result.type).toEqual(CONFIRM_REMOVE_ANNOTATION);
expect(result.id).toEqual('1');
});

it('changedProperties', () => {
const field = "desc";
const value = "desc value";
const result = changedProperties(field, value);
expect(result.type).toEqual(CHANGED_PROPERTIES);
expect(result.field).toEqual(field);
expect(result.value).toEqual(value);
});
it('cancel remove annotation', () => {
const result = cancelRemoveAnnotation();
expect(result.type).toEqual(CANCEL_REMOVE_ANNOTATION);
});

it('setUnsavedChanges', () => {
const result = setUnsavedChanges(true);
expect(result.type).toEqual(UNSAVED_CHANGES);
expect(result.unsavedChanges).toEqual(true);
});
it('setUnsavedStyle', () => {
const result = setUnsavedStyle(true);
expect(result.type).toEqual(UNSAVED_STYLE);
expect(result.unsavedStyle).toEqual(true);
});
it('cancel edit annotation', () => {
const result = cancelEditAnnotation();
expect(result.type).toEqual(CANCEL_EDIT_ANNOTATION);
});

it('stopDrawing', () => {
const result = stopDrawing();
expect(result.type).toEqual(STOP_DRAWING);
});
it('toggleUnsavedChangesModal', () => {
const result = toggleUnsavedChangesModal();
expect(result.type).toEqual(TOGGLE_CHANGES_MODAL);
});
it('toggleUnsavedStyleModal', () => {
const result = toggleUnsavedStyleModal();
expect(result.type).toEqual(TOGGLE_STYLE_MODAL);
});
it('saveText', () => {
const text = "asdfasf!";
const result = saveText(text);
expect(result.type).toEqual(SAVE_TEXT);
expect(result.value).toEqual(text);
});
it('changeStyler', () => {
const stylerType = "marker";
const result = changeStyler(stylerType);
expect(result.type).toEqual(CHANGE_STYLER);
expect(result.stylerType).toEqual(stylerType);
});
it('save annotation', () => {
const result = saveAnnotation('1', {
name: 'changed'
Expand Down Expand Up @@ -168,9 +232,8 @@ describe('Test correctness of the annotations actions', () => {
});

it('creates new annotation', () => {
const result = newAnnotation('Point');
const result = newAnnotation();
expect(result.type).toEqual(NEW_ANNOTATION);
expect(result.featureType).toEqual('Point');
});

it('highlights annotation', () => {
Expand Down
20 changes: 20 additions & 0 deletions web/client/actions/__tests__/draw-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ describe('Test correctness of the draw actions', () => {
expect(retval.features).toExist();
expect(retval.features).toBe(features);
});
it('Test geometryChanged features, owner, enableEdit, textChanged', () => {
const features = [{
geometry: {
type: "Point",
coordinates: []
}
}];
const owner = "annotations";
const enableEdit = true;
const textChanged = false;
const retval = geometryChanged(features, owner, enableEdit, textChanged);

expect(retval).toExist();
expect(retval.type).toBe(GEOMETRY_CHANGED);
expect(retval.features).toExist();
expect(retval.features).toBe(features);
expect(retval.owner).toBe(owner);
expect(retval.enableEdit).toBe(enableEdit);
expect(retval.textChanged).toBe(textChanged);
});
it('Test drawStopped action creator', () => {
const retval = drawStopped();
expect(retval).toExist();
Expand Down
Loading