]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#347] Narrow file:// test restriction to JSONP tests
authorrwldrn <waldron.rick@gmail.com>
Tue, 22 Feb 2011 17:29:31 +0000 (12:29 -0500)
committerrwldrn <waldron.rick@gmail.com>
Tue, 22 Feb 2011 17:29:31 +0000 (12:29 -0500)
test/popcorn.unit.js

index e355c7849ea0be5e5d363ed1465c2d1fad1ff442..ea062b7f66e6fa79894a10258f5ad87c66cf87d3 100644 (file)
@@ -1,16 +1,3 @@
-
-if ( /file/.test( location.protocol ) ) {
-
-  test("HTTP", function () {
-    
-    ok( false, "Please run test suite via an HTTP connection" );
-    
-  });
-  
-  throw "Please run test suite via an HTTP connection";
-}
-
-
 module("Popcorn");
 test("API", function () {
   
@@ -1219,89 +1206,94 @@ test("dataType: JSON Response", function () {
 
 });
 
-test("JSONP Response", function () {
 
-  var expects = 8, 
-      count = 0;
-      
-  function plus() {
-    if ( ++count === expects ) {
-      start();
-    }
-  }
-  
-  expect(expects);
-  
-  stop(10000);
+if ( !/file/.test( location.protocol ) ) {
 
+  test("JSONP Response", function () {
 
-  var testObj = { "data": {"lang": "en", "length": 25} };  
+    var expects = 8, 
+        count = 0;
 
-  Popcorn.xhr({
-    
-    url: 'data/jsonp.php?callback=jsonp',
-    dataType: 'jsonp', 
-    success: function( data ) {
-      
-      ok(data, "getJSONP returns data");
-      plus();
-      
-      
-      ok( QUnit.equiv(data, testObj) , "Popcorn.xhr({}) data.json returns an object of data");
-      plus();
-      
+    function plus() {
+      if ( ++count === expects ) {
+        start();
+      }
     }
-  });
 
-  Popcorn.xhr.getJSONP(
-    'data/jsonp.php?callback=jsonp',
+    expect(expects);
 
-    function( data ) {
-      
-      ok(data, "getJSONP returns data");
-      plus();
-      
-      
-      
-      ok( QUnit.equiv(data, testObj) , "Popcorn.xhr.getJSONP data.json returns an object of data");
-      plus();
-      
-    }
-  );
+    stop(10000);
 
-  Popcorn.xhr.getJSONP(
-    "http://api.flickr.com/services/feeds/photos_public.gne?id=35034346917@N01&lang=en-us&format=json&jsoncallback=flickr",
 
-    function( data ) {
-      
-      
-      
-      ok(data, "getJSONP returns flickr data");
-      plus();
+    var testObj = { "data": {"lang": "en", "length": 25} };  
 
-      equal( typeof data, "object", "getJSONP returns flickr data");
-      plus();      
+    Popcorn.xhr({
 
-      
-    }
-  );  
+      url: 'data/jsonp.php?callback=jsonp',
+      dataType: 'jsonp', 
+      success: function( data ) {
 
-  Popcorn.getJSONP(
-    'data/jsonp.php?callback=jsonp',
+        ok(data, "getJSONP returns data");
+        plus();
 
-    function( data ) {
-      
-      ok(data, "getJSONP returns data");
-      plus();
-      
-      
-      
-      ok( QUnit.equiv(data, testObj) , "Popcorn.xhr.getJSONP data.json returns an object of data");
-      plus();
-      
-    }
-  );  
-});
+
+        ok( QUnit.equiv(data, testObj) , "Popcorn.xhr({}) data.json returns an object of data");
+        plus();
+
+      }
+    });
+
+    Popcorn.xhr.getJSONP(
+      'data/jsonp.php?callback=jsonp',
+
+      function( data ) {
+
+        ok(data, "getJSONP returns data");
+        plus();
+
+
+
+        ok( QUnit.equiv(data, testObj) , "Popcorn.xhr.getJSONP data.json returns an object of data");
+        plus();
+
+      }
+    );
+
+    Popcorn.xhr.getJSONP(
+      "http://api.flickr.com/services/feeds/photos_public.gne?id=35034346917@N01&lang=en-us&format=json&jsoncallback=flickr",
+
+      function( data ) {
+
+
+
+        ok(data, "getJSONP returns flickr data");
+        plus();
+
+        equal( typeof data, "object", "getJSONP returns flickr data");
+        plus();      
+
+
+      }
+    );  
+
+    Popcorn.getJSONP(
+      'data/jsonp.php?callback=jsonp',
+
+      function( data ) {
+
+        ok(data, "getJSONP returns data");
+        plus();
+
+
+
+        ok( QUnit.equiv(data, testObj) , "Popcorn.xhr.getJSONP data.json returns an object of data");
+        plus();
+
+      }
+    );  
+  });
+
+}
 
 test("Popcorn.getScript()", function () {