Skip to content
Snippets Groups Projects
Commit fedaefb4 authored by imranasghar96@hotmail.com's avatar imranasghar96@hotmail.com
Browse files

Update tests

parent f8f957b0
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,9 @@ import WebAnnotation from '../src/WebAnnotation'; ...@@ -3,7 +3,9 @@ import WebAnnotation from '../src/WebAnnotation';
/** */ /** */
function createSubject(args = {}) { function createSubject(args = {}) {
return new WebAnnotation({ return new WebAnnotation({
body: 'body', body: {
value: 'body',
},
canvasId: 'canvasId', canvasId: 'canvasId',
id: 'id', id: 'id',
svg: 'svg', svg: 'svg',
...@@ -17,10 +19,15 @@ describe('WebAnnotation', () => { ...@@ -17,10 +19,15 @@ describe('WebAnnotation', () => {
let subject = createSubject(); let subject = createSubject();
describe('constructor', () => { describe('constructor', () => {
it('sets instance accessors', () => { it('sets instance accessors', () => {
['body', 'canvasId', 'id', 'svg', 'xywh'].forEach((prop) => { ['canvasId', 'id', 'svg', 'xywh'].forEach((prop) => {
expect(subject[prop]).toBe(prop); expect(subject[prop]).toBe(prop);
}); });
}); });
it('sets instance accessors for body', () => {
['body'].forEach((prop) => {
expect(subject[prop].value).toBe(prop);
});
});
}); });
describe('target', () => { describe('target', () => {
it('with svg and xywh', () => { it('with svg and xywh', () => {
......
...@@ -86,6 +86,7 @@ class AnnotationCreation extends Component { ...@@ -86,6 +86,7 @@ class AnnotationCreation extends Component {
annoState.image = props.annotation.body.image; annoState.image = props.annotation.body.image;
} }
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') {
...@@ -98,6 +99,7 @@ class AnnotationCreation extends Component { ...@@ -98,6 +99,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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment