Skip to content

Commit

Permalink
Update the updateAnnotation method (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
maddocash authored and pogotc committed Jan 28, 2020
1 parent cd91e18 commit 99dc897
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion babel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '\'');
}
}
Expand Down
5 changes: 3 additions & 2 deletions babel/test/unit/babel_client_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "talis-node",
"version": "0.1.4",
"version": "0.1.5",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 99dc897

Please sign in to comment.