From: rwldrn Date: Tue, 22 Feb 2011 17:29:31 +0000 (-0500) Subject: [#347] Narrow file:// test restriction to JSONP tests X-Git-Tag: v0.4~34^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0b41adc68cf60e0f86eed7149c99a9d2902e9db4;p=popcorn-js.git [#347] Narrow file:// test restriction to JSONP tests --- diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index e355c78..ea062b7 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -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 () {