From eee893ba21e46437c3e47563f085c0c5cceb8ec4 Mon Sep 17 00:00:00 2001 From: Matthew Schranz Date: Fri, 2 Mar 2012 18:15:14 -0500 Subject: [PATCH] [#930]Fixed unit tests. Removed one because can't handle errors being thrown from async (xhr) properly. Replaced with somewhat elegant message to user instead --- plugins/tumblr/popcorn.tumblr.js | 4 +++- plugins/tumblr/popcorn.tumblr.unit.js | 28 ++++++++------------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/plugins/tumblr/popcorn.tumblr.js b/plugins/tumblr/popcorn.tumblr.js index b1d821fc..b013cdba 100644 --- a/plugins/tumblr/popcorn.tumblr.js +++ b/plugins/tumblr/popcorn.tumblr.js @@ -387,7 +387,9 @@ } } else { // There was an error somewhere down the line that caused the request to fail. - Popcorn.error( "Error. Request failed. Status code: " + data.meta.status + " - Message: " + data.meta.msg ); + commonDiv.innerHTML += "Error. Request failed. Status code: " + data.meta.status + " - Message: " + data.meta.msg + + "
This could be due to an invalid blogId."; + options._container.appendChild( commonDiv ); } }, false ); } diff --git a/plugins/tumblr/popcorn.tumblr.unit.js b/plugins/tumblr/popcorn.tumblr.unit.js index 11cdf2ef..fa9be764 100644 --- a/plugins/tumblr/popcorn.tumblr.unit.js +++ b/plugins/tumblr/popcorn.tumblr.unit.js @@ -124,9 +124,11 @@ test( "Popcorn Tumblr Plugin", function () { test( "Test Initialized Tumblr Blocks throwing Errors", function () { - var pop = Popcorn( "#video" ), expects = 6; + Popcorn.plugin.debug = true; - expect( 6 ); + var pop = Popcorn( "#video" ), expects = 5; + + expect( expects ); // Tests for thrown Error on emtpy block try { @@ -137,7 +139,7 @@ test( "Test Initialized Tumblr Blocks throwing Errors", function () { // Tests for thrown Error on invalid plugin type try { - pop.facebook({ + pop.tumblr({ requestType: "asdadsadasad", target: "testsdiv", start: 1, @@ -151,7 +153,7 @@ test( "Test Initialized Tumblr Blocks throwing Errors", function () { // No blogId supplied for blogpost request try { - pop.facebook({ + pop.tumblr({ requestType: "blogpost", target: "testsdiv", start: 1, @@ -165,7 +167,7 @@ test( "Test Initialized Tumblr Blocks throwing Errors", function () { // Checking no API KEY try { - pop.facebook({ + pop.tumblr({ requestType: "blogpost", target: "testsdiv", start: 1, @@ -179,7 +181,7 @@ test( "Test Initialized Tumblr Blocks throwing Errors", function () { // Checking no base_hostname provided try { - pop.facebook({ + pop.tumblr({ requestType: "blogpost", target: "testsdiv", start: 1, @@ -191,19 +193,5 @@ test( "Test Initialized Tumblr Blocks throwing Errors", function () { ok( true, "Caught no base_hostname for blogpost type." ); } - // Checking for a failure in request from API using an invalid blogId - try { - pop.facebook({ - requestType: "blogpost", - target: "testsdiv", - start: 1, - end: 5, - blogId: 1, - base_hostname: "tumblrplugin.tumblr.com", - api_key: "7lQpV9mMr2PiYjd20FavZcmReq8cWU0oHTS6d3YIB8rLUQvvcg" - }); - } catch( e ) { - ok( true, "Caught failed request from API for blogpost type." ); - } });