-
-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 () {
});
-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 () {