From 9923475cadf38d18c93215ea07070e15c1aa5481 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 20 Jul 2011 18:09:54 -0400 Subject: [PATCH] [#624] Improves parsejson tests --- parsers/parserJSON/popcorn.parserJSON.unit.js | 97 ++++++------------- 1 file changed, 31 insertions(+), 66 deletions(-) diff --git a/parsers/parserJSON/popcorn.parserJSON.unit.js b/parsers/parserJSON/popcorn.parserJSON.unit.js index e6ecb0b..b63d04a 100644 --- a/parsers/parserJSON/popcorn.parserJSON.unit.js +++ b/parsers/parserJSON/popcorn.parserJSON.unit.js @@ -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); - }); -- 2.43.0