@annotation-studio/redux
Advanced tools
Comparing version 1.0.0-pr.b8f203c7 to 1.0.0-pr.c1ff24c2
@@ -5,3 +5,2 @@ import AnnotationSelector from '../AnnotationSelector'; | ||
it('should retain partOf', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -26,2 +25,3 @@ id: 'http://canvas/#xywh=1,2,3,4', | ||
id: 'http://canvas/#xywh=1,2,3,4', | ||
type: 'Canvas', | ||
'dcterms:isPartOf': 'http://manifest', | ||
@@ -32,3 +32,2 @@ }); | ||
it('should ignore partOf if not found', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -35,0 +34,0 @@ id: 'http://canvas/#xywh=1,2,3,4', |
import Annotation from '../Annotation'; | ||
import { | ||
createAnnotationFromCaptureModelAndDraft, createExternalResourceAnnotationBody, | ||
createAnnotationFromCaptureModelAndDraft, | ||
createExternalResourceAnnotationBody, | ||
createHumanReadableAnnotationBody, | ||
@@ -26,6 +27,3 @@ } from '../mapping'; | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -83,3 +81,4 @@ id: null, | ||
label: 'Testing annotation', | ||
url: 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
url: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
}, | ||
@@ -111,7 +110,12 @@ }, | ||
describe('lib/annotation/annotation#tagging-draft', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft, partOf: 'http://some-manifest' }), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
partOf: 'http://some-manifest', | ||
}) | ||
); | ||
@@ -121,24 +125,26 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'type': 'Annotation', | ||
'label': 'Testing annotation', | ||
'body': [ | ||
type: 'Annotation', | ||
label: 'Testing annotation', | ||
body: [ | ||
{ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}, | ||
{ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}, | ||
], | ||
'generator': 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
'target': { | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
target: { | ||
'dcterms:isPartOf': 'http://some-manifest', | ||
'id': 'http://manifest', | ||
type: 'Canvas', | ||
id: 'http://manifest', | ||
}, | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
@@ -150,9 +156,10 @@ }); | ||
const bodies = jsonify( | ||
createExternalResourceAnnotationBody(captureModel, draft), | ||
createExternalResourceAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}); | ||
@@ -163,11 +170,11 @@ }); | ||
const bodies = jsonify( | ||
createHumanReadableAnnotationBody(captureModel, draft), | ||
createHumanReadableAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}); | ||
}); | ||
}); |
@@ -123,2 +123,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
id: this.getStringSelector(), | ||
type: 'Canvas', | ||
'dcterms:isPartOf': this.selector.partOf | ||
@@ -125,0 +126,0 @@ }; |
@@ -129,3 +129,2 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
export function createExternalResourceAnnotationBody(captureModel, draft) { | ||
var fieldIds = Object.keys(draft.input); | ||
@@ -158,3 +157,2 @@ var fields = getModelFields(fieldIds, captureModel.fields); | ||
}).reduce(function (state, field) { | ||
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && field.inputType === 'madoc:textarea') { | ||
@@ -161,0 +159,0 @@ var body = new AnnotationBody(null, draft.input[field.id], 'text/plain', 'TextualBody'); |
@@ -5,3 +5,2 @@ import AnnotationSelector from '../AnnotationSelector'; | ||
it('should retain partOf', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -26,2 +25,3 @@ id: 'http://canvas/#xywh=1,2,3,4', | ||
id: 'http://canvas/#xywh=1,2,3,4', | ||
type: 'Canvas', | ||
'dcterms:isPartOf': 'http://manifest', | ||
@@ -32,3 +32,2 @@ }); | ||
it('should ignore partOf if not found', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -35,0 +34,0 @@ id: 'http://canvas/#xywh=1,2,3,4', |
import Annotation from '../Annotation'; | ||
import { | ||
createAnnotationFromCaptureModelAndDraft, createExternalResourceAnnotationBody, | ||
createAnnotationFromCaptureModelAndDraft, | ||
createExternalResourceAnnotationBody, | ||
createHumanReadableAnnotationBody, | ||
@@ -26,6 +27,3 @@ } from '../mapping'; | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -83,3 +81,4 @@ id: null, | ||
label: 'Testing annotation', | ||
url: 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
url: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
}, | ||
@@ -111,7 +110,12 @@ }, | ||
describe('lib/annotation/annotation#tagging-draft', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft, partOf: 'http://some-manifest' }), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
partOf: 'http://some-manifest', | ||
}) | ||
); | ||
@@ -121,24 +125,26 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'type': 'Annotation', | ||
'label': 'Testing annotation', | ||
'body': [ | ||
type: 'Annotation', | ||
label: 'Testing annotation', | ||
body: [ | ||
{ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}, | ||
{ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}, | ||
], | ||
'generator': 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
'target': { | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
target: { | ||
'dcterms:isPartOf': 'http://some-manifest', | ||
'id': 'http://manifest', | ||
type: 'Canvas', | ||
id: 'http://manifest', | ||
}, | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
@@ -150,9 +156,10 @@ }); | ||
const bodies = jsonify( | ||
createExternalResourceAnnotationBody(captureModel, draft), | ||
createExternalResourceAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}); | ||
@@ -163,11 +170,11 @@ }); | ||
const bodies = jsonify( | ||
createHumanReadableAnnotationBody(captureModel, draft), | ||
createHumanReadableAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}); | ||
}); | ||
}); |
@@ -135,2 +135,3 @@ 'use strict'; | ||
id: this.getStringSelector(), | ||
type: 'Canvas', | ||
'dcterms:isPartOf': this.selector.partOf | ||
@@ -137,0 +138,0 @@ }; |
@@ -167,3 +167,2 @@ 'use strict'; | ||
function createExternalResourceAnnotationBody(captureModel, draft) { | ||
var fieldIds = Object.keys(draft.input); | ||
@@ -196,3 +195,2 @@ var fields = getModelFields(fieldIds, captureModel.fields); | ||
}).reduce(function (state, field) { | ||
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && field.inputType === 'madoc:textarea') { | ||
@@ -199,0 +197,0 @@ var body = new _AnnotationBody2.default(null, draft.input[field.id], 'text/plain', 'TextualBody'); |
{ | ||
"name": "@annotation-studio/redux", | ||
"version": "1.0.0-pr.b8f203c7", | ||
"version": "1.0.0-pr.c1ff24c2", | ||
"description": "Describe annotation-redux here", | ||
@@ -38,3 +38,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@fesk/test-environment": "^1.0.0-pr.b8f203c7", | ||
"@fesk/test-environment": "^1.0.0-pr.c1ff24c2", | ||
"babel-jest": "^20.0.3", | ||
@@ -48,3 +48,3 @@ "babel-plugin-transform-async-to-generator": "^6.24.1", | ||
"nwb": "^0.21.5", | ||
"nwb-watch": "^1.0.0-pr.b8f203c7", | ||
"nwb-watch": "^1.0.0-pr.c1ff24c2", | ||
"react-intl": "^2.2.2", | ||
@@ -51,0 +51,0 @@ "react-intl-redux": "^0.7.0", |
338974
8898