# HG changeset patch # User hamidouk # Date 1324976765 -3600 # Node ID 3cc4a789dae718cdce81ac5704d71593e4066d7b # Parent 3ebf62837492ff55894cbdf4fc77df6bf7fa8a50 added unit tests for sparklineWidget diff -r 3ebf62837492 -r 3cc4a789dae7 unittests/index.html --- a/unittests/index.html Fri Dec 23 16:40:43 2011 +0100 +++ b/unittests/index.html Tue Dec 27 10:06:05 2011 +0100 @@ -17,6 +17,8 @@ + + @@ -46,12 +48,15 @@ - + + + diff -r 3ebf62837492 -r 3cc4a789dae7 unittests/tests/init.js --- a/unittests/tests/init.js Fri Dec 23 16:40:43 2011 +0100 +++ b/unittests/tests/init.js Tue Dec 27 10:06:05 2011 +0100 @@ -96,14 +96,14 @@ mode: "radio", metadata:{ format:'cinelab', - src:'test.json', + src:'../test/test.json', type:'dummy'}, requires: [ {type: "PlayerWidget", mode: "radio", metadata:{ format:'cinelab', - src:'test.json', + src:'../test/test.json', type:'dummy' } }] }; @@ -119,7 +119,6 @@ var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542}); var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions); - var widgets = IriSP.configureWidgets(pop, layoutManager, this.widgetOptions); ok(widgets[0] instanceof IriSP.PlayerWidget, "first widget is a player widget"); diff -r 3ebf62837492 -r 3cc4a789dae7 unittests/tests/widgets/sparklineWidget.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/unittests/tests/widgets/sparklineWidget.js Tue Dec 27 10:06:05 2011 +0100 @@ -0,0 +1,39 @@ +/* sparklineWidget.js */ + +function test_sparkline_widget() { + module("Sparkline widget testing", + {setup : function() { + this.Popcorn = Popcorn("#popcorn-div"); + + this.dt = new IriSP.DataLoader(); + this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ + + + this.config = { + width:650, + height:1, + mode:'radio', + container:'widget-div', + debug:true, + css:'../src/css/LdtPlayer.css'}; + }, + teardown: function() { + /* free the popcorn object because it has signal handlers attached to it */ + this.Popcorn = Popcorn("#popcorn-div"); + } + }); + + test("test widget initialization", function() { + + var widget = new IriSP.SparklineWidget(this.Popcorn, this.config, this.ser); + widget.draw(); + + equal(widget.selector.children(".Ldt-SparklineWidget").length, 1, "test if the div has been added correctly"); + + /* + widget._Popcorn.currentTime(400); + widget._Popcorn.trigger("timeupdate"); + equal(widget.selector.children(".Ldt-SparklineWidget").css("left"), "22%", "test if the widget responds correctly to messages."); + */ + }); + };