]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
#332 Added unit tests
authorMohammed Buttu <mohammedbuttu@gmail.com>
Wed, 18 May 2011 16:46:00 +0000 (12:46 -0400)
committerMohammed Buttu <mohammedbuttu@gmail.com>
Wed, 18 May 2011 16:46:00 +0000 (12:46 -0400)
plugins/linkedin/popcorn.linkedin.unit.html
plugins/linkedin/popcorn.linkedin.unit.js

index c9adf62f0b41525dc7a502216600a2f6d0731f52..f9caeb26d81a1263b6cba87571a76b14997f1901 100644 (file)
     <p>Your user agent does not support the HTML5 Video element.</p> 
 
   </video> 
-  <div id="linkedindiv"></div>  
+  <div id="sharediv"></div>
+  <div id="recommenddiv"></div>
+  <div id="memberprofilediv"></div>
+  <div id="companyinsiderdiv"></div>
+  <div id="companyprofilediv"></div>  
 </body>
 </html>
index cdd4e63d4fb42cb9b84a17714577bab3d60a8fb5..2c23c20a48fff578f68c754ece1e453c6637478f 100644 (file)
@@ -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 {