]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#245] passing unit tests
authorrwldrn <waldron.rick@gmail.com>
Thu, 20 Jan 2011 22:08:49 +0000 (17:08 -0500)
committerrwldrn <waldron.rick@gmail.com>
Thu, 20 Jan 2011 22:08:49 +0000 (17:08 -0500)
parsers/parserJSON/popcorn.parserJSON.unit.js

index 1a6e2fba36f2eb91c08e6bb479c7ce994a91b1d4..6312a2f187d0aadd8b687f7c38e355a42dad0e62 100644 (file)
@@ -4,6 +4,7 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
       count = 0,
       timeOut = 0,
       numLoadingEvents = 5, 
+      finished = false,
       trackData,
       trackEvents, 
       interval,
@@ -23,78 +24,59 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
   
   stop( 10000 );
   
-  
 
-  
-  setTimeout(function () {
-  
-    trackData = poppercorn.data;
-    trackEvents = trackData.trackEvents;
-    
+  trackData = poppercorn.data;
+  trackEvents = trackData.trackEvents;
 
-    equals( trackEvents.byStart.length,  numLoadingEvents + 2 , "trackEvents.byStart.length === (5 loaded, 2 padding) " );
-    plus();  
-  
-  
-    Popcorn.xhr({
-      url: 'data/data.json', 
-      success: function( data ) {
-        
-        var idx = 0;
-        
-        Popcorn.forEach( data.json.data, function (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" );
-            plus();
-            
-            idx++;
-          });
+  Popcorn.xhr({
+    url: 'data/data.json', 
+    success: function( data ) {
+
+      var idx = 0;
+
+      Popcorn.forEach( data.json.data, function (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" );
+          plus();
+
+          idx++;
         });
-        
-        
-      }
-    });
-    
-    
-    
-    
-    poppercorn.listen("timeupdate", function ( event ) {
-
-      if ( Math.round( this.currentTime()) === 3 ) {
+      });
+
+
+    }
+  });  
+  poppercorn.listen("timeupdate", function ( event ) {
+  
+
+    if ( Math.round( this.currentTime()) === 3 && !finished ) {
       
-        equals( $("#iframe-container").children().length, 2, '$("#iframe-container").children().length' )
-        plus();
-        equals( $("#map-container").children().length, 1, '$("#map-container").children().length'  );
-        plus();
-        equals( $("#footnote-container").children().length, 2, '$("#footnote-container").children().length'  );
-        plus();
-        
-        this.pause();
+      finished = true;
       
-      }
+      equals( trackEvents.byStart.length,  numLoadingEvents + 2 , "trackEvents.byStart.length === (5 loaded, 2 padding) " );
+      plus();  
 
-    
-    });
-    
-    
-    poppercorn.currentTime(0).play()
 
+      equals( $("#iframe-container").children().length, 2, '$("#iframe-container").children().length' )
+      plus();
+      equals( $("#map-container").children().length, 1, '$("#map-container").children().length'  );
+      plus();
+      equals( $("#footnote-container").children().length, 2, '$("#footnote-container").children().length'  );
+      plus();
+
+      this.pause();
+
+    }
+
+
+  });
+
+  setTimeout(function () {
   
-  }, 500);
-  
-  
-  
-  
-  
-  
-  
-  
+    poppercorn.currentTime(0).play()
 
-  // interval used to wait for data to be parsed
-  //interval = setInterval( function() {
-    //poppercorn.currentTime(5).play().currentTime(6);
-  //}, 2000);
+  }, 500);
   
 });