unittests/tests/widgets/tooltipWidget.js
branchnew-model
changeset 924 64c2eaafe5e2
parent 923 b3ee7d1b472a
child 925 28efc97b5d78
equal deleted inserted replaced
923:b3ee7d1b472a 924:64c2eaafe5e2
     1 /* tooltipWidget.js */
       
     2 
       
     3 function test_tooltip_widget() {
       
     4   module("tooltip 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     this.config = {
       
    12 							width: 160,
       
    13 							height:120,
       
    14               container: "widget-div"
       
    15 						};
       
    16     },
       
    17     
       
    18   teardown: function() {
       
    19     /* free the popcorn object because it has signal handlers attached to it */
       
    20     this.Popcorn = Popcorn("#popcorn-div");
       
    21   }
       
    22   });
       
    23   
       
    24   test("test tooltip widget initialization", function() {  
       
    25     var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
       
    26     widget.draw();
       
    27 
       
    28     equal(widget.selector.children(".tip").length, 1, "test if the div has been added correctly");
       
    29     equal(widget.selector.children(".tip").css("position"), "fixed", "test if the widget has the correct position attr");    
       
    30     equal(widget.selector.children(".tip").css("display"), "none", "test if tooltip is hidden");    
       
    31   });
       
    32   
       
    33   test("test widget display function", function() {
       
    34     var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
       
    35     widget.draw();
       
    36     
       
    37     widget.show("ceci est un texte", "#fefefe", 105, 240);
       
    38     equal(widget.selector.children(".tip").css("left"), "105px", "test if div has been positionned correctly");
       
    39     equal(widget.selector.children(".tip").css("top"), "240px", "test if div has been positionned correctly");    
       
    40     equal(widget.selector.find(".tiptext").text(), "ceci est un texte", "test if text has been set correctly");
       
    41     notEqual(widget.selector.children(".tip").css("display"), "none", "test if tooltip is hidden"); 
       
    42     
       
    43     widget.hide();
       
    44     equal(widget.selector.children(".tip").css("display"), "none", "test if tooltip is hidden"); 
       
    45   });
       
    46 };