]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#624] Improves parsejson tests
authorRick Waldron <waldron.rick@gmail.com>
Wed, 20 Jul 2011 22:09:54 +0000 (18:09 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Wed, 20 Jul 2011 22:09:54 +0000 (18:09 -0400)
parsers/parserJSON/popcorn.parserJSON.unit.js

index e6ecb0b472767d99556530786cee49af6506152b..b63d04ac62adfc7faec6d409169d1f9280b20c63 100644 (file)
@@ -1,32 +1,32 @@
 test("Popcorn 0.3 JSON Parser Plugin", function () {
-  
+
   var expects = 9,
       count = 0,
       timeOut = 0,
-      numLoadingEvents = 5, 
+      numLoadingEvents = 5,
       finished = false,
       trackData,
-      trackEvents, 
+      trackEvents,
       poppercorn = Popcorn( "#video" );
-      
+
   function plus() {
     if ( ++count === expects ) {
       start();
     }
   }
-  
+
   poppercorn.parseJSON("data/video.json");
-  
+
   expect(expects);
-  
+
   stop( 10000 );
-  
+
 
   trackData = poppercorn.data;
   trackEvents = trackData.trackEvents;
 
   Popcorn.xhr({
-    url: 'data/video.json', 
+    url: 'data/video.json',
     success: function( data ) {
 
       var idx = 0;
@@ -35,7 +35,7 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
 
       Popcorn.forEach( data.json.data, function (dataObj) {
 
-       //console.log( dataObj );
+        //console.log( dataObj );
         Popcorn.forEach( dataObj, function ( obj, key ) {
 
           equals( trackData.history[idx].indexOf(key), 0, "history item '" + trackData.history[idx] + "' matches data key '"+ key+ "' at correct index" );
@@ -47,16 +47,17 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
 
 
     }
-  });  
+  });
+
   poppercorn.listen("timeupdate", function ( event ) {
-  
+
 
     if ( Math.round( this.currentTime()) === 3 && !finished ) {
-      
+
       finished = true;
-      
+
       equals( trackEvents.byStart.length,  numLoadingEvents + 2 , "trackEvents.byStart.length === (5 loaded, 2 padding) " );
-      plus();  
+      plus();
 
 
       equals( $("#video-iframe-container").children().length, 2, '$("#video-iframe-container").children().length' )
@@ -69,30 +70,23 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
       this.pause();
 
     }
-
-
   });
 
-  setTimeout(function () {
-  
-    poppercorn.currentTime(0).play()
-
-  }, 500);
-  
+  poppercorn.currentTime(0).play()
 });
 
 test("Popcorn 0.3 JSON Parser Plugin - AUDIO", function () {
-  
-  var expects = 9,
+
+  var expects = 5,
       count = 0,
       timeOut = 0,
-      numLoadingEvents = 5, 
+      numLoadingEvents = 5,
       finished = false,
       trackData,
-      trackEvents, 
+      trackEvents,
       interval,
       audiocorn = Popcorn.getInstanceById("audio");
-      
+
   function plus() {
     if ( ++count === expects ) {
       start();
@@ -102,25 +96,27 @@ test("Popcorn 0.3 JSON Parser Plugin - AUDIO", function () {
   }
 
   expect(expects);
-  
-  stop( 5000 );
-  
+
+  stop();
+
 
   trackData = audiocorn.data;
   trackEvents = trackData.trackEvents;
 
 
   Popcorn.xhr({
-    url: 'data/audio.json', 
+    url: 'data/audio.json',
     success: function( data ) {
 
       var idx = 0;
 
-      Popcorn.forEach( data.json.data, function (dataObj) {
-        Popcorn.forEach( dataObj, function ( obj, key ) {
+      Popcorn.forEach( data.json.data, function( dataObj ) {
+        Popcorn.forEach( dataObj, function( obj, key ) {
 
+          var historyItem = trackData.history[ idx ];
 
-          equals( trackData.history[idx].indexOf(key), 0, "history item '" + trackData.history[idx] + "' matches data key '"+ key+ "' at correct index" );
+          console.log( historyItem, key );
+          equal( historyItem.indexOf(key), 0, "history item '" + historyItem + "' matches data key '"+ key+ "' at correct index" );
           plus();
 
           idx++;
@@ -129,38 +125,7 @@ test("Popcorn 0.3 JSON Parser Plugin - AUDIO", function () {
 
 
     }
-  });  
-  audiocorn.listen("timeupdate", function ( event ) {
-  
-
-    if ( Math.round( this.currentTime()) === 3 && !finished ) {
-      
-      finished = true;
-      
-      equals( trackEvents.byStart.length,  numLoadingEvents + 2 , "trackEvents.byStart.length === (5 loaded, 2 padding) " );
-      plus();  
-
-
-      equals( $("#audio-iframe-container").children().length, 2, '$("#audio-iframe-container").children().length' )
-      plus();
-      equals( $("#audio-map-container").children().length, 1, '$("#audio-map-container").children().length'  );
-      plus();
-      equals( $("#audio-footnote-container").children().length, 2, '$("#audio-footnote-container").children().length'  );
-      plus();
-
-      this.pause();
-
-    }
-
-
   });
 
-
-  setTimeout(function () {
-  
-    audiocorn.currentTime(0).play()
-
-  }, 500);
-  
 });