From 99dc897a03bd6c14083b28d915ec4233d789b968 Mon Sep 17 00:00:00 2001 From: Maddocash <31258232+maddocash@users.noreply.github.com> Date: Tue, 28 Jan 2020 15:28:20 +0000 Subject: [PATCH] Update the updateAnnotation method (#17) --- babel/index.js | 3 ++- babel/test/unit/babel_client_test.js | 5 +++-- package.json | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/babel/index.js b/babel/index.js index 1ef4d2c..cc795bb 100644 --- a/babel/index.js +++ b/babel/index.js @@ -437,7 +437,8 @@ BabelClient.prototype.updateAnnotation = function updateAnnotation(token, data, } for (var prop in target) { if(target.hasOwnProperty(prop)){ - if (!(prop === 'uri' || prop === 'fragment' || prop === 'asReferencedBy' )) { + const validProps = ["uri", "fragment", "asReferencedBy", "type"]; + if (validProps.indexOf(prop) === -1) { throw new Error('Invalid data: hasTarget has unrecognised property \'' + prop + '\''); } } diff --git a/babel/test/unit/babel_client_test.js b/babel/test/unit/babel_client_test.js index 5d74b77..57ac2a2 100644 --- a/babel/test/unit/babel_client_test.js +++ b/babel/test/unit/babel_client_test.js @@ -1376,7 +1376,8 @@ describe("Babel Node Client Test Suite", function(){ annotatedAt: '2015-02-03T10:28:37.725Z', motivatedBy: 'The Combine', hasTarget: { - uri: 'http://example.com/uri' + uri: 'http://example.com/uri', + type: 'Text' }, hasBody:{ format: 'text/plain', @@ -1393,7 +1394,7 @@ describe("Babel Node Client Test Suite", function(){ babel.__set__("request", requestMock); - babelClient.updateAnnotation('secret', {_id: 'testid', hasBody:{format:'text/plain', type:'Text'}, hasTarget:{uri:'http://example.com'}, annotatedBy:'Gordon Freeman'}, function(err, result){ + babelClient.updateAnnotation('secret', {_id: 'testid', hasBody:{format:'text/plain', type:'Text'}, hasTarget:{uri:'http://example.com', type: 'Text'}, annotatedBy:'Gordon Freeman'}, function(err, result){ (err === null).should.be.true; result.annotatedBy.should.equal('Gordon Freeman'); result.hasTarget.uri.should.equal('http://example.com/uri'); diff --git a/package.json b/package.json index c3c2ada..79ac9d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "talis-node", - "version": "0.1.4", + "version": "0.1.5", "description": "", "main": "index.js", "scripts": {