|
1 /* tweetsWidget.js */ |
|
2 |
|
3 function test_tweets_widget() { |
|
4 module("tweet 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.MockTweetSerializer(this.dt, "/url"); /* dummy serializer */ |
|
10 |
|
11 this.config = { |
|
12 width:650, |
|
13 height:1, |
|
14 mode:'radio', |
|
15 container:'widget-div', |
|
16 debug:true, |
|
17 css:'../src/css/LdtPlayer.css'}; |
|
18 }, |
|
19 teardown: function() { |
|
20 /* free the popcorn object because it has signal handlers attached to it */ |
|
21 this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); |
|
22 } |
|
23 }); |
|
24 |
|
25 test("test widget initialization", function() { |
|
26 var widget = new IriSP.TweetsWidget(this.Popcorn, this.config, this.ser); |
|
27 widget.draw(); |
|
28 |
|
29 equal(widget.selector.children(".Ldt-tweetAvatar").length, 1, "test if the div has been added correctly"); |
|
30 equal(widget.selector.children(".Ldt-tweetContents").length, 1, "test if sub-div has been added correctly"); |
|
31 }); |
|
32 |
|
33 test("test tweet display function", function() { |
|
34 var widget = new IriSP.TweetsWidget(this.Popcorn, this.config, this.ser); |
|
35 widget.draw(); |
|
36 var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}}; |
|
37 widget.displayTweet(annotation); |
|
38 |
|
39 equal(widget.selector.find(".Ldt-tweetContents").text(), "title", "title set correctly"); |
|
40 // equal(widget.selector.find(".Ldt-SaDescription").text(), "description", "description set correctly"); |
|
41 // equal(widget.selector.find(".Ldt-SaKeywordText").text(), "", "keywords field set correctly"); |
|
42 }); |
|
43 }; |