Skip to content
Snippets Groups Projects
Commit 299aa363 authored by Lutz Helm's avatar Lutz Helm
Browse files

Fix #46: expect annotation without target selector

parent d6b55e03
No related branches found
No related tags found
No related merge requests found
...@@ -36,4 +36,16 @@ describe('AnnotationCreation', () => { ...@@ -36,4 +36,16 @@ describe('AnnotationCreation', () => {
wrapper = createWrapper(); wrapper = createWrapper();
expect(wrapper.dive().find(TextEditor).length).toBe(1); expect(wrapper.dive().find(TextEditor).length).toBe(1);
}); });
it('can handle annotations without target selector', () => {
wrapper = createWrapper({
annotation: {
body: {
purpose: 'commenting',
value: 'Foo bar',
},
target: {},
},
});
wrapper.dive();
});
}); });
...@@ -50,6 +50,7 @@ class AnnotationCreation extends Component { ...@@ -50,6 +50,7 @@ class AnnotationCreation extends Component {
} else { } else {
annoState.annoBody = props.annotation.body.value; annoState.annoBody = props.annotation.body.value;
} }
if (props.annotation.target.selector) {
if (Array.isArray(props.annotation.target.selector)) { if (Array.isArray(props.annotation.target.selector)) {
props.annotation.target.selector.forEach((selector) => { props.annotation.target.selector.forEach((selector) => {
if (selector.type === 'SvgSelector') { if (selector.type === 'SvgSelector') {
...@@ -62,6 +63,7 @@ class AnnotationCreation extends Component { ...@@ -62,6 +63,7 @@ class AnnotationCreation extends Component {
annoState.svg = props.annotation.target.selector.value; annoState.svg = props.annotation.target.selector.value;
} }
} }
}
this.state = { this.state = {
activeTool: 'cursor', activeTool: 'cursor',
annoBody: '', annoBody: '',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment