unittests/tests/widgets/annotationsWidget.js
branchpopcorn-port
changeset 234 43b198dc932d
child 284 cbb17aa3361c
equal deleted inserted replaced
233:126de77ee73e 234:43b198dc932d
       
     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     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.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
       
    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     equal(widget.selector.children(".Ldt-AnnotationsWidget").find(".Ldt-SaKeyword").length, 1, "test if sub-div has been added correctly");
       
    33   });
       
    34   
       
    35   test("test annotation display function", function() {
       
    36     var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
       
    37     widget.draw();
       
    38     var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}};
       
    39     widget.displayAnnotation(annotation);
       
    40     equal(widget.selector.find(".Ldt-SaTitle").text(), "title", "title set correctly");
       
    41     equal(widget.selector.find(".Ldt-SaDescription").text(), "description", "description set correctly");
       
    42     equal(widget.selector.find(".Ldt-SaKeywordText").text(), "", "keywords field set correctly");
       
    43   });
       
    44 };