This repository has been archived by the owner on Jan 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from xgaia/js_test
Positionable Tests
- Loading branch information
Showing
5 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,4 +88,4 @@ describe('AskomicsLink', function(){ | |
chai.assert.deepEqual(variates, []); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/*jshint esversion: 6 */ | ||
|
||
describe('AskomicsPositionableLink', function(){ | ||
let node1 = new GraphNode({ uri:"http://wwww.system/test1",label:'',_id: 15, _SPARQLid: "HelloWorldNode1", _suggested: false }, 12.5,16.3); | ||
let node2 = new GraphNode({ uri:"http://wwww.system/test2",_id: 16, _SPARQLid: "HelloWorlNode2", _suggested: true }, 14.1,26.3); | ||
let link = new AskomicsPositionableLink({ uri:'http://wwww.system/link1'},node1,node2); | ||
describe('#Constructeur empty', function(){ | ||
it('* test constructor *', function(){ | ||
chai.assert.deepEqual(link.type, 'included'); | ||
chai.assert.deepEqual(link.label, 'included in'); | ||
chai.assert.deepEqual(link.same_tax, true); | ||
chai.assert.deepEqual(link.same_ref, true); | ||
chai.assert.deepEqual(link.strict, true); | ||
}); | ||
}); | ||
|
||
describe('#SetJSON', function() { | ||
it('* test setjson() *', function() { | ||
let link2 = new AskomicsPositionableLink({ uri:'http://wwww.system/link1'},node1,node2); | ||
let JSON_link = { | ||
"_id": 11, | ||
"_SPARQLid": "positionable1", | ||
"_suggested": false, | ||
"_uri": "positionable", | ||
"_label": "excluded of", | ||
"_linkindex": 1, | ||
"_source": {}, | ||
"_target": {}, | ||
"_transitive": true, | ||
"_negative": false, | ||
"type": "excluded", | ||
"same_tax": false, | ||
"same_ref": true, | ||
"strict": false | ||
} | ||
|
||
chai.expect(function () { link2.setjson(JSON_link); }).to.throw('Devel error: setjson : obj._source have no id property : {"_id":11,"_SPARQLid":"positionable1","_suggested":false,"_uri":"positionable","_label":"excluded of","_linkindex":1,"_source":{},"_target":{},"_transitive":true,"_negative":false,"type":"excluded","same_tax":false,"same_ref":true,"strict":false}'); | ||
//FIXME: setJSON without throwing an error | ||
//link.setjson(JSON_link); | ||
//chai.assert.deepEqual(link, JSON_link); | ||
}); | ||
}); | ||
|
||
|
||
describe('#BuiltConstraintSPARQL', function() { | ||
it('* test the constraints *', function() { | ||
let expectedResult = [ | ||
[ | ||
"?URI :position_taxon ?taxon_", | ||
"?URI :position_ref ?ref_", | ||
"?URI :position_taxon ?taxon_", | ||
"?URI :position_ref ?ref_", | ||
"?URI :position_start ?start_", | ||
"?URI :position_end ?end_", | ||
"?URI :position_start ?start_", | ||
"?URI :position_end ?end_", | ||
"FILTER(?ref_ = ?ref_)", | ||
"FILTER(?taxon_ = ?taxon_)", | ||
"FILTER((?start_ > ?start_ ) && (?end_ < ?end_))" | ||
], | ||
"" | ||
]; | ||
chai.assert.deepEqual(link.buildConstraintsSPARQL(), expectedResult); | ||
}); | ||
}); | ||
|
||
|
||
describe('#BuiltFiltersSPARQL', function() { | ||
it('* test the filters *', function() { | ||
let expectedResult = [ | ||
"FILTER(?ref_ = ?ref_)", | ||
"FILTER(?taxon_ = ?taxon_)", | ||
"FILTER((?start_ > ?start_ ) && (?end_ < ?end_))" | ||
]; | ||
let filters = []; | ||
link.buildFiltersSPARQL(filters); | ||
chai.assert.deepEqual(filters, expectedResult); | ||
}); | ||
|
||
it('* test the error *', function() { | ||
let link2 = link; | ||
let filters = []; | ||
link2.type = 'bla'; | ||
chai.expect(function () { link2.buildFiltersSPARQL(filters); }).to.throw("buildPositionableConstraintsGraph: unkown type: bla"); | ||
|
||
}); | ||
}); | ||
|
||
describe('#Positionable link Display methods', function(){ | ||
it('* String output *', function(){ | ||
chai.assert.typeOf(link.getFillColor(),'string'); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*jshint esversion: 6 */ | ||
|
||
//define a positionable node | ||
let PositionableNodeJSON = { | ||
"_id": 0, | ||
"_SPARQLid": "helloWorld", | ||
"_suggested": false, | ||
"_uri": "http://test.askomics#helloWorld", | ||
"_label": "helloWorld", | ||
"_actif": true, | ||
"_weight": 1, | ||
"_x": 0.0, | ||
"_y": 0.0, | ||
"_nlink": {}, | ||
"_attributes": {}, | ||
"_categories": {}, | ||
"_filters": {}, | ||
"_values": {}, | ||
"_isregexp": {}, | ||
"_inverseMatch": {} | ||
} | ||
|
||
|
||
describe('AskomicsPositionableNode', function(){ | ||
describe('#Constructor/JSON', function(){ | ||
it('* test all methods *', function(){ | ||
let positionableNode = new AskomicsPositionableNode({uri:"http://wwww.system/test1"},0.0,0.0); | ||
positionableNode.setjson(PositionableNodeJSON); | ||
chai.assert.deepEqual(positionableNode, PositionableNodeJSON); | ||
}); | ||
}); | ||
|
||
describe('#Attribute Graph Display methods', function(){ | ||
it('* String output *', function(){ | ||
let nodeEmpty = new AskomicsPositionableNode({ label:"helloWorld", uri:"/huoulu/lolo/dddddd#", _id: 15, _SPARQLid: "HelloWorld16", _suggested: true }, 12.5,16.3); | ||
chai.assert.typeOf(nodeEmpty.getTextFillColor(),'string'); | ||
chai.assert.typeOf(nodeEmpty.getTextStrokeColor(),'string'); | ||
chai.assert.typeOf(nodeEmpty.getNodeFillColor(),'string'); | ||
}); | ||
}); | ||
}); |