added a basic test for segmentsWidget.js search. popcorn-port
authorhamidouk
Thu, 27 Oct 2011 11:22:49 +0200
branchpopcorn-port
changeset 157 73bce42a3ed3
parent 156 0e6a4d1e4dbe
child 158 1813e6e4f0d6
added a basic test for segmentsWidget.js search.
src/js/widgets/segmentsWidget.js
unittests/mockSerializer.js
unittests/tests/segmentsWidget.js
--- a/src/js/widgets/segmentsWidget.js	Wed Oct 26 17:21:35 2011 +0200
+++ b/src/js/widgets/segmentsWidget.js	Thu Oct 27 11:22:49 2011 +0200
@@ -102,10 +102,10 @@
   for (var id in matches) {
     var factor = matches[id] * 8;
     IriSP.jQuery("#"+id).dequeue();
-    IriSP.jQuery("#"+id).animate({height: factor},200);
+    IriSP.jQuery("#"+id).animate({height: factor}, 200);
     IriSP.jQuery("#"+id).css('border','2px');
     IriSP.jQuery("#"+id).css('border-color','red');
-    IriSP.jQuery("#"+id).animate({opacity:0.6},200);
+    IriSP.jQuery("#"+id).animate({opacity:0.6}, 200);
 
     //IriSP.jQuery("#LdtSearchInput").css('background-color','#e1ffe1');
   }
--- a/unittests/mockSerializer.js	Wed Oct 26 17:21:35 2011 +0200
+++ b/unittests/mockSerializer.js	Thu Oct 27 11:22:49 2011 +0200
@@ -4,8 +4,22 @@
 
 IriSP.MockSerializer = function(DataLoader, url) {
   IriSP.Serializer.call(this, DataLoader, url);
+  this._data = _data;
+};
 
-  this._data = { "tags": [
+IriSP.MockSerializer.prototype = new IriSP.Serializer();   
+
+IriSP.MockSerializer.prototype.currentMedia = function() {
+  return this._data.medias[0];
+};
+
+// Copy some methods from JSONSerializer because we need them in
+// some tests.
+
+IriSP.MockSerializer.prototype.searchAnnotations = IriSP.JSONSerializer.prototype.searchAnnotations;
+IriSP.MockSerializer.prototype.searchOccurences = IriSP.JSONSerializer.prototype.searchOccurences;
+
+var _data = { "tags": [
       {
           "meta": {
             "dc:contributor": "IRI ", 
@@ -1458,12 +1472,4 @@
           "dc:description": "", 
           "dc:modified": "2010-09-06T15:53:44.699595"
         }
-      ]
-};
-};
-
-IriSP.MockSerializer.prototype = new IriSP.Serializer();   
-
-IriSP.MockSerializer.prototype.currentMedia = function() {
-  return this._data.medias[0];
-};
+      ]};
\ No newline at end of file
--- a/unittests/tests/segmentsWidget.js	Wed Oct 26 17:21:35 2011 +0200
+++ b/unittests/tests/segmentsWidget.js	Thu Oct 27 11:22:49 2011 +0200
@@ -47,10 +47,23 @@
     this.Popcorn.listen("timeupdate", spy_callback);    
     
     var selector = IriSP.jQuery("#Ldt-Annotations :not(first-child)");
-    var random = Math.round(Math.random() * selector.length);
+    var random = Math.round(Math.random() * selector.length) + 1;
     selector.eq(random).click();
         
     ok(spy_callback.called, "the currenttime was changed");         
     ok(spy_handler.called, "handling function has been called");           
   });
+  
+  test("test search highlight features", function() {
+  
+    var tag_id = "#s_" + "82613B88-9578-DC2C-D7D0-B2C5BE0B7BDA".toUpperCase();
+    
+    var widget = new IriSP.SegmentsWidget(this.Popcorn, this.config, this.ser);
+    widget.draw();    
+
+    var oldStyle = IriSP.jQuery("#Ldt-Annotations").children(tag_id).attr("style");
+    widget._Popcorn.trigger("IriSP.search", "sociologie");
+    var newStyle = IriSP.jQuery("#Ldt-Annotations").children(tag_id).attr("style");
+    notEqual(oldStyle, newStyle, "the segment style has been modified");
+  });
 }; 
\ No newline at end of file