# HG changeset patch # User hamidouk # Date 1320332829 -3600 # Node ID 7a963ec3e09a6b16a790f04e55d8f01528b12a9f # Parent 2ccec620126137670d0284128c7fff8ac8c1135d added tests for the polemicWidget. diff -r 2ccec6201261 -r 7a963ec3e09a unittests/index.html --- a/unittests/index.html Thu Nov 03 16:05:52 2011 +0100 +++ b/unittests/index.html Thu Nov 03 16:07:09 2011 +0100 @@ -31,6 +31,7 @@ + diff -r 2ccec6201261 -r 7a963ec3e09a unittests/tests/polemicWidget.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/unittests/tests/polemicWidget.js Thu Nov 03 16:07:09 2011 +0100 @@ -0,0 +1,51 @@ +/* polemicWidget.js */ + +function test_polemic_widget() { + module("polemic widget testing", + {setup : function() { + this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + + this.dt = new IriSP.DataLoader(); + this.ser = new IriSP.MockTweetSerializer(this.dt, "/url"); /* dummy serializer */ + + IriSP.jQuery("#widget-div").append("
"); + IriSP.jQuery("#widget-div").append("
"); + this.config = { + metadata:{ + format:'cinelab', + src:'test.json', + load:'json'}, + width:650, + height:1, + mode:'radio', + container:'PolemicDiv', + debug:true, + css:'../src/css/LdtPlayer.css', + requires: [{ + type: "TooltipWidget", + container: "TooltipDiv", + width: 180, + heigh: 160, + metadata : { + format:'cinelab', + type:'empty' + } + }] + } + }, + teardown: function() { + /* free the popcorn object because it has signal handlers attached to it */ + this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + }}); + + test("test widget initialization", function() { + + var tooltip = new IriSP.TooltipWidget(this.Popcorn, this.config.requires[0], this.ser); + var widget = new IriSP.PolemicWidget(this.Popcorn, this.config, this.ser); + widget.TooltipWidget = tooltip; + + widget.draw(); + equal(IriSP.jQuery("#widget-div").length, 1, "test if the div has been added correctly"); + equal(IriSP.jQuery("#PolemicDiv").children().length, 1, "test if children have been added correctly"); + }); +}; \ No newline at end of file