From d1084e91d911c7d87af154c54eaef2d1fd77cec1 Mon Sep 17 00:00:00 2001 From: Matthew Schranz Date: Wed, 28 Sep 2011 19:12:14 -0400 Subject: [PATCH] [#734] Added _teardown method. Added unit tests for _teardown. --- plugins/facebook/popcorn.facebook.js | 19 +++++-------------- plugins/facebook/popcorn.facebook.unit.js | 8 ++++---- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/plugins/facebook/popcorn.facebook.js b/plugins/facebook/popcorn.facebook.js index 0ae26b9..2ec920b 100755 --- a/plugins/facebook/popcorn.facebook.js +++ b/plugins/facebook/popcorn.facebook.js @@ -46,7 +46,7 @@ * This will show how many people "like" Seneca College's Facebook page, and show their profile pictures */ - var ranOnce = false, idx = 0; + var ranOnce = false; Popcorn.plugin( "facebook" , { manifest: { @@ -165,17 +165,8 @@ _setup: function( options ) { var target = document.getElementById( options.target ), - _type = options.type, - facebookdiv; - - /* - // Ensure target container chosen by user exists - if ( !target && Popcorn.plugin.debug ) { - throw new Error( "Facebook target container doesn't exist" ); - } - target && target.appendChild( containerDiv ); - */ - + _type = options.type; + // facebook script requires a div named fb-root if ( !document.getElementById( "fb-root" ) ) { var fbRoot = document.createElement( "div" ); @@ -262,8 +253,8 @@ }, _teardown: function( options ){ var target = document.getElementById( options.target ); - target && target.removeChild( options._facebookdiv ); + target && target.removeChild( options._container ); } }); -})( Popcorn, this ); \ No newline at end of file +})( Popcorn, this ); diff --git a/plugins/facebook/popcorn.facebook.unit.js b/plugins/facebook/popcorn.facebook.unit.js index 5d70e65..8602fb8 100755 --- a/plugins/facebook/popcorn.facebook.unit.js +++ b/plugins/facebook/popcorn.facebook.unit.js @@ -39,7 +39,7 @@ test( "Popcorn Facebook Plugin", function () { }) .volume( 0 ) .play(); - + setupId = popped.getLastTrackEventId(); ok ( document.getElementById( "activitydiv" ), "activitydiv exists on the page" ); @@ -57,12 +57,12 @@ test( "Popcorn Facebook Plugin", function () { popped.exec( 5, function() { ok( document.getElementById( "facepilediv" ).innerHTML, "Facepilediv is not empty at 0:05 (expected)" ); plus(); - + popped.pause().removeTrackEvent( setupId ); - ok( !facepilediv, "removed facebook social plugin was properly destroyed" ); + ok( !document.getElementById( "facepilediv" ).innerHTML, "removed facebook social plugin was properly destroyed" ); plus(); }); - + }); -- 2.43.0