]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
#332 Added a check to make sure the unit tests are being run on localhost
authorMohammed Buttu <mohammedbuttu@gmail.com>
Mon, 16 May 2011 17:01:27 +0000 (13:01 -0400)
committerMohammed Buttu <mohammedbuttu@gmail.com>
Mon, 16 May 2011 17:01:27 +0000 (13:01 -0400)
plugins/linkedin/popcorn.linkedin.unit.js

index fb34528e28b41c2a1980f3633eb2bcd1709a993c..a72d96e1fe47058d9b31621f7d18f5be1dab4ec6 100644 (file)
@@ -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");
+  }
 });