From 78b1a799a15b6a708d8228d01203ec4253f2b72f Mon Sep 17 00:00:00 2001 From: rwldrn Date: Thu, 20 Jan 2011 17:08:49 -0500 Subject: [PATCH] [#245] passing unit tests --- parsers/parserJSON/popcorn.parserJSON.unit.js | 110 ++++++++---------- 1 file changed, 46 insertions(+), 64 deletions(-) diff --git a/parsers/parserJSON/popcorn.parserJSON.unit.js b/parsers/parserJSON/popcorn.parserJSON.unit.js index 1a6e2fb..6312a2f 100644 --- a/parsers/parserJSON/popcorn.parserJSON.unit.js +++ b/parsers/parserJSON/popcorn.parserJSON.unit.js @@ -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); }); -- 2.43.0