From 7bd6f22b8451492127c1f609d84b15ed76778da5 Mon Sep 17 00:00:00 2001 From: Mohammed Buttu Date: Mon, 16 May 2011 13:01:27 -0400 Subject: [PATCH] #332 Added a check to make sure the unit tests are being run on localhost --- plugins/linkedin/popcorn.linkedin.unit.js | 94 ++++++++++++----------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/plugins/linkedin/popcorn.linkedin.unit.js b/plugins/linkedin/popcorn.linkedin.unit.js index fb34528..a72d96e 100644 --- a/plugins/linkedin/popcorn.linkedin.unit.js +++ b/plugins/linkedin/popcorn.linkedin.unit.js @@ -1,51 +1,59 @@ test("Popcorn LinkedIn Plugin", function () { - var popped = Popcorn("#video"), - expects = 5, - count = 0, - linkedin = document.getElementById('linkedindiv'); + if ( /localhost/.test( location.hostname ) ) { + + // run tests on localhost + var popped = Popcorn("#video"), + expects = 5, + count = 0, + linkedin = document.getElementById('linkedindiv'); + + expect( expects ); + + function plus() { - expect( expects ); - - function plus() { - - if ( ++count === expects ) { - start(); + if ( ++count === expects ) { + start(); + } } - } - - stop(); - - ok( 'linkedin' in popped, "linkedin is a method of the popped instance" ); - plus(); - - equals( linkedin.innerHTML, "", "initially, there is nothing inside the linkedin div" ); - plus(); - popped.linkedin({ - - type : 'share', - counter : 'right', - url : "http://www.google.ca", - target : "linkedindiv", - apikey : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk', - start : 1, - end : 3 - }); - - popped.exec( 2, function() { - - ok( /block/.test( linkedin.style.display ), "Div contents are displayed" ); - plus(); - ok( /script/.test( linkedin.innerHTML ), "LinkedIn plugin exists" ); - plus(); - }); + stop(); + + ok( 'linkedin' in popped, "linkedin is a method of the popped instance" ); + plus(); - popped.exec( 4, function() { - - ok( /none/.test( linkedin.style.display ), "Div contents are hidden again" ); - plus(); - }); + equals( linkedin.innerHTML, "", "initially, there is nothing inside the linkedin div" ); + plus(); + + popped.linkedin({ + + type : 'share', + counter : 'right', + url : "http://www.google.ca", + target : "linkedindiv", + apikey : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk', + start : 1, + end : 3 + }); + + popped.exec( 2, function() { + + ok( /block/.test( linkedin.style.display ), "Div contents are displayed" ); + plus(); + ok( /script/.test( linkedin.innerHTML ), "LinkedIn plugin exists" ); + plus(); + }); + + popped.exec( 4, function() { + + ok( /none/.test( linkedin.style.display ), "Div contents are hidden again" ); + plus(); + }); + + popped.volume(0).play(); + } else { - popped.volume(0).play(); + // tests must be run on localhost + ok(false, "LinkedIn apikey will only work under localhost"); + } }); -- 2.43.0