|
93
|
1 |
/* annotationsWidget.js */ |
|
|
2 |
|
|
|
3 |
function test_annotations_widget() { |
|
|
4 |
module("annotations widget testing", |
|
|
5 |
{setup : function() { |
|
|
6 |
this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); |
|
|
7 |
|
|
|
8 |
this.dt = new IriSP.DataLoader(); |
|
|
9 |
this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
IriSP.jQuery("#widget-div").append("<div id='Ldt-Ligne'></div>"); |
|
|
13 |
this.config = { |
|
|
14 |
metadata:{ |
|
|
15 |
format:'cinelab', |
|
|
16 |
src:'test.json', |
|
|
17 |
load:'json'}, |
|
|
18 |
gui:{ |
|
|
19 |
width:650, |
|
|
20 |
height:1, |
|
|
21 |
mode:'radio', |
|
|
22 |
container:'widget-div', |
|
|
23 |
debug:true, |
|
|
24 |
css:'../src/css/LdtPlayer.css'}, |
|
|
25 |
}; |
|
|
26 |
}, |
|
|
27 |
teardown: function() { |
|
|
28 |
/* free the popcorn object because it has signal handlers attached to it */ |
|
|
29 |
this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); |
|
|
30 |
} |
|
|
31 |
}); |
|
|
32 |
|
|
|
33 |
test("test widget initialization", function() { |
|
|
34 |
var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser); |
|
|
35 |
widget.draw(); |
|
|
36 |
|
|
|
37 |
equal(IriSP.jQuery("#Ldt-Ligne").length, 1, "test if the div has been added correctly"); |
|
|
38 |
equal(IriSP.jQuery("#Ldt-Ligne #Ldt-SaKeyword").length, 1, "test if sub-div has been added correctly"); |
|
|
39 |
}); |
|
|
40 |
|
|
|
41 |
test("test annotation display function", function() { |
|
|
42 |
var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser); |
|
|
43 |
widget.draw(); |
|
|
44 |
var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}}; |
|
|
45 |
widget.displayAnnotation(annotation); |
|
|
46 |
equal(IriSP.jQuery("#Ldt-SaTitle").text(), "title", "title set correctly"); |
|
|
47 |
equal(IriSP.jQuery("#Ldt-SaDescription").text(), "description", "description set correctly"); |
|
|
48 |
equal(IriSP.jQuery("#Ldt-SaKeywordText").text(), "Mots clefs : ", "keywords field set correctly"); |
|
|
49 |
}); |
|
|
50 |
}; |