-
Notifications
You must be signed in to change notification settings - Fork 0
/
unitTest.html
116 lines (102 loc) · 5.17 KB
/
unitTest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>QUnit Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.1.1.css">
<script src="https://code.jquery.com/qunit/qunit-2.1.1.js"></script>
<script type="text/javascript" src="scripts/inheritance.js"></script>
<script type="text/javascript" src="scripts/jquery.tooltip.js"></script>
<script type="text/javascript" src="scripts/jOWL.js"></script>
<script type="text/javascript" src="scripts/jOWL_UI.js"></script>
<script type="text/javascript" src="scripts/jOWLBrowser.js"></script>
<script type="text/javascript" src="scripts/jowl.thing.js"></script>
<script type="text/javascript" src="scripts/jowl.element.js"></script>
<script type="text/javascript" src="scripts/jowl.document.js"></script>
<script type="text/javascript" src="scripts/jowl.datatype.js"></script>
<script type="text/javascript" src="scripts/jowl.ontology.js"></script>
<script type="text/javascript" src="scripts/jowl.individual.js"></script>
<script type="text/javascript" src="scripts/jowl.property.js"></script>
<script type="text/javascript" src="scripts/jowl.class.js"></script>
<script type="text/javascript" src="scripts/jowl.intersection.js"></script>
<script type="text/javascript" src="scripts/jowl.restriction.js"></script>
<script type="text/javascript">
$(document).ready(function(){
jOWL.load("data/wine.owl", function(document){
function assertResources(assert, childCollection){
var names = Array.prototype.slice.call(arguments, 2);
var actualNames = childCollection.map(function(){
return this.name;
});
assert.deepEqual(actualNames.sort(), names.sort(), 'Resources equivalence');
}
QUnit.test("Ontology Description", function(assert){
var onto = document.getOntology();
assert.equal(onto.description()[0], "An example OWL ontology");
});
QUnit.test("Wine Test", function(assert){
var wine = document.getResource("Wine");
assert.notOk(wine.isExternal, "Wine is internal");
console.log(wine.terms());
assert.equal(wine.label(), 'wine');
assert.equal(wine.label('fr'), 'vin');
console.log('children', wine.children());
assertResources(assert, wine.parents(), "PotableLiquid");
});
QUnit.test("Individual WhitehallLaneCabernetFranc", function(assert){
var ind = document.getResource("WhitehallLaneCabernetFranc");
var clazz = ind.owlClass();
assert.equal(clazz.URI, "CabernetFranc");
});
QUnit.test("Burgundy Test", function(assert){
var resource = document.getResource("Burgundy");
assert.notOk(resource.isExternal, "Burgundy is internal");
assertResources(assert, resource.children(), "WhiteBurgundy", "RedBurgundy");
assertResources(assert, resource.parents(), "TableWine");
assert.ok(true, "Table wine is defined as a wine which is dry... which is actually wrong... Burgundy is dry....");
//Table wine is defined as a wine which is dry... which is actually wrong...
//Burgundy is dry....
assertResources(assert, resource.sourceof(), "hasSugar#Dry",
"locatedIn#FrenchRegion",
"locatedIn#BourgogneRegion",
"hasMaker#undefined",
"madeFromGrape#undefined",
"hasFlavor#undefined",
"hasBody#undefined",
"hasColor#undefined");
//console.log("Burgundy source", resource.sourceof());
});
QUnit.test("WhiteBurgundy Test", function(assert){
var resource = document.getResource("WhiteBurgundy");
assert.notOk(resource.isExternal, "WhiteBurgundy is internal");
assertResources(assert, resource.children(), "Meursault");
assertResources(assert, resource.parents(), "Burgundy", "WhiteWine");
assertResources(assert, resource.ancestors(), "Burgundy", "TableWine", "Wine", "PotableLiquid", "WhiteWine");
// assertResources(assert, resource.children(), "WhiteBurgundy", "RedBurgundy");
//assertResources(assert, resource.parents(), "Wine");
//console.log("source", resource.sourceof());
});
//white wines which are either dry or offdry
QUnit.test("WhiteNonSweetWine Test", function(assert){
var resource = document.getResource("WhiteNonSweetWine");
assert.notOk(resource.isExternal, "WhiteNonSweetWine is internal");
console.log('children WhiteNonSweetWine', resource.children());
//DryRiesling...
//assertChildren(assert, resource.children(), "WhiteBurgundy", "RedBurgundy");
});
QUnit.test("WineGrape Test", function(assert){
var resource = document.getResource("WineGrape");
assert.notOk(resource.isExternal, "WineGrape is internal");
//has an external parent!
});
}, {locale : 'en'});
});
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>