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