unittests/tests/widgets/sparklineWidget.js
author hamidouk
Tue, 27 Dec 2011 10:06:05 +0100
branchpopcorn-port
changeset 530 3cc4a789dae7
permissions -rw-r--r--
added unit tests for sparklineWidget
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
530
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     1
/* sparklineWidget.js */
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     2
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     3
function test_sparkline_widget() {
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     4
  module("Sparkline widget testing", 
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     5
  {setup : function() {    
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     6
    this.Popcorn = Popcorn("#popcorn-div");
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     7
    
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     8
    this.dt = new IriSP.DataLoader();
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
     9
    this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    10
        
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    11
    
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    12
    this.config = {
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    13
							width:650,
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    14
							height:1,
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    15
							mode:'radio',
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    16
							container:'widget-div',
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    17
							debug:true,
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    18
							css:'../src/css/LdtPlayer.css'};
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    19
    },
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    20
  teardown: function() {
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    21
    /* free the popcorn object because it has signal handlers attached to it */
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    22
    this.Popcorn = Popcorn("#popcorn-div");
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    23
  }
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    24
  });
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    25
  
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    26
  test("test widget initialization", function() {  
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    27
  
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    28
    var widget = new IriSP.SparklineWidget(this.Popcorn, this.config, this.ser);    
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    29
    widget.draw();
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    30
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    31
    equal(widget.selector.children(".Ldt-SparklineWidget").length, 1, "test if the div has been added correctly");
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    32
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    33
    /*
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    34
    widget._Popcorn.currentTime(400);
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    35
    widget._Popcorn.trigger("timeupdate");
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    36
    equal(widget.selector.children(".Ldt-SparklineWidget").css("left"), "22%", "test if the widget responds correctly to messages.");
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    37
  */
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    38
  });
3cc4a789dae7 added unit tests for sparklineWidget
hamidouk
parents:
diff changeset
    39
 };