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;
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" );
}
- });
+ });
+
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' )
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();
}
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++;
}
- });
- 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);
-
});