From 6f71faa56d4ba4f161b4ee9b3eed3626b63bac65 Mon Sep 17 00:00:00 2001 From: Mohammed Buttu Date: Wed, 18 May 2011 12:46:00 -0400 Subject: [PATCH] #332 Added unit tests --- plugins/linkedin/popcorn.linkedin.unit.html | 6 +- plugins/linkedin/popcorn.linkedin.unit.js | 141 ++++++++++++++++++-- 2 files changed, 134 insertions(+), 13 deletions(-) diff --git a/plugins/linkedin/popcorn.linkedin.unit.html b/plugins/linkedin/popcorn.linkedin.unit.html index c9adf62..f9caeb2 100644 --- a/plugins/linkedin/popcorn.linkedin.unit.html +++ b/plugins/linkedin/popcorn.linkedin.unit.html @@ -37,6 +37,10 @@

Your user agent does not support the HTML5 Video element.

-
+
+
+
+
+
diff --git a/plugins/linkedin/popcorn.linkedin.unit.js b/plugins/linkedin/popcorn.linkedin.unit.js index cdd4e63..2c23c20 100644 --- a/plugins/linkedin/popcorn.linkedin.unit.js +++ b/plugins/linkedin/popcorn.linkedin.unit.js @@ -4,10 +4,14 @@ test("Popcorn LinkedIn Plugin", function () { // run tests on localhost var popped = Popcorn("#video"), - expects = 6, + expects = 22, count = 0, setupId, - linkedin = document.getElementById( "linkedindiv" ); + sharediv = document.getElementById( "sharediv" ), + recommenddiv = document.getElementById( "recommenddiv" ), + memberprofilediv = document.getElementById( "memberprofilediv" ), + companyinsiderdiv = document.getElementById( "companyinsiderdiv" ), + companyprofilediv = document.getElementById( "companyprofilediv" ); expect( expects ); @@ -23,40 +27,153 @@ test("Popcorn LinkedIn Plugin", function () { ok( "linkedin" in popped, "linkedin is a method of the popped instance" ); plus(); - equals( linkedin.innerHTML, "", "initially, there is nothing inside the linkedin div" ); + // Testing the share plugin + equals( sharediv.innerHTML, "", "initially, there is nothing inside the sharediv" ); plus(); popped.linkedin({ - type: "share", counter: "right", url: "http://www.google.ca", - target: "linkedindiv", + target: "sharediv", apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", start: 1, end: 3 }); - setupId = popped.getLastTrackEventId(); - popped.exec( 2, function() { - ok( /block/.test( linkedin.style.display ), "Div contents are displayed" ); + ok( /block/.test( sharediv.style.display ), "sharediv contents are displayed" ); plus(); - ok( /script/.test( linkedin.innerHTML ), "LinkedIn plugin exists" ); + ok( /script/.test( sharediv.innerHTML ), "share plugin exists" ); plus(); }); popped.exec( 4, function() { - ok( /none/.test( linkedin.style.display ), "Div contents are hidden again" ); + ok( /none/.test( sharediv.style.display ), "sharediv contents are hidden again" ); + plus(); + }); + + // Testing the recommendproduct plugin + equals( recommenddiv.innerHTML, "", "initially, there is nothing inside the recommenddiv" ); + plus(); + + popped.linkedin({ + type: "recommendproduct", + counter: "top", + target: "recommenddiv", + companyid: "LinkedIn", + productid: "201714", + apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", + start: 5, + end: 7 + }); + + popped.exec( 6, function() { + + ok( /block/.test( recommenddiv.style.display ), "recommenddiv contents are displayed" ); + plus(); + ok( /script/.test( recommenddiv.innerHTML ), "recommend plugin exists" ); + plus(); + }); + + popped.exec( 8, function() { + + ok( /none/.test( recommenddiv.style.display ), "recommenddiv contents are hidden again" ); + plus(); + }); + + // Testing memberprofile plugin + equals( memberprofilediv.innerHTML, "", "initially, there is nothing inside the memberprofilediv" ); + plus(); + + popped.linkedin({ + type: "memberprofile", + memberid: "/in/jeffweiner08", + format: "inline", + target: "memberprofilediv", + apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", + start: 9, + end: 11 + }); + + popped.exec( 10, function() { + + ok( /block/.test( memberprofilediv.style.display ), "memberprofilediv contents are displayed" ); + plus(); + ok( /script/.test( memberprofilediv.innerHTML ), "member profile plugin exists" ); + plus(); + }); + + popped.exec( 12, function() { + + ok( /none/.test( memberprofilediv.style.display ), "memberprofilediv contents are hidden again" ); + plus(); + }); + + // Testing the company insider plugin + equals( companyinsiderdiv.innerHTML, "", "initially, there is nothing inside the companyinsiderdiv" ); + plus(); + + popped.linkedin({ + type: "companyinsider", + companyid: "1441", + target: "companyinsiderdiv", + apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", + start: 13, + end: 15 + }); + + popped.exec( 14, function() { + + ok( /block/.test( companyinsiderdiv.style.display ), "companyinsiderdiv contents are displayed" ); + plus(); + ok( /script/.test( companyinsiderdiv.innerHTML ), "company insider plugin exists" ); + plus(); + }); + + popped.exec( 16, function() { + + ok( /none/.test( companyinsiderdiv.style.display ), "companyinsiderdiv contents are hidden again" ); + plus(); + }); + + // Testing company profile plugin + equals( companyprofilediv.innerHTML, "", "initially, there is nothing inside the companyprofilediv" ); + plus(); + + popped.linkedin({ + type: "companyprofile", + companyid: "1441", + format: "inline", + target: "companyprofilediv", + apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", + start: 17, + end: 19 + }); + + setupId = popped.getLastTrackEventId(); + + popped.exec( 18, function() { + + ok( /block/.test( companyprofilediv.style.display ), "companyprofilediv contents are displayed" ); + plus(); + ok( /script/.test( companyprofilediv.innerHTML ), "company profile plugin exists" ); + plus(); + }); + + popped.exec( 20, function() { + + ok( /none/.test( companyprofilediv.style.display ), "companyprofilediv contents are hidden again" ); plus(); + // Make sure _teardown functionality works popped.pause().removeTrackEvent( setupId ); - ok( !linkedin.children[1], "removed linkedin was properly destroyed" ); + ok( !companyprofilediv.children[1], "companyprofilediv plugin was properly destroyed" ); plus(); }); - + popped.volume( 0 ).play(); } else { -- 2.43.0