From faa2ebd297ba24653e2bcf6722d96fb8cdbcf7a2 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Wed, 22 Dec 2010 12:46:16 -0500 Subject: [PATCH] modify test so it runs locally --- src/ajax.js | 9 ++++----- test/ajax.html | 4 ++-- test/fixtures/jsonp.js | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 test/fixtures/jsonp.js diff --git a/src/ajax.js b/src/ajax.js index c460e7c8c..605960188 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -7,9 +7,9 @@ $.ajaxJSONP = function(options){ var jsonpString; jsonpString = 'jsonp' + ++jsonpID; - window[jsonpString] = function(j){ options.success(j) } + window[jsonpString] = options.success; var script = document.createElement('script'); - $(script).attr({ src: options.url.replace(/callback=\?/, 'callback=' + jsonpString), type: 'text/javascript' }); + $(script).attr({ src: options.url.replace(/callback=\?/, 'callback=' + jsonpString) }); $('head').append(script); }; @@ -17,9 +17,8 @@ // { type, url, data, success, dataType, contentType } options = options || {}; - if (options.url && /callback=\?/.test(options.url)) { - return $.ajaxJSONP(options) - } + if (options.url && /callback=\?/.test(options.url)) + return $.ajaxJSONP(options); var data = options.data, callback = options.success || empty, diff --git a/test/ajax.html b/test/ajax.html index f9750f3e0..5f098e82b 100644 --- a/test/ajax.html +++ b/test/ajax.html @@ -65,9 +65,9 @@

Zepto Ajax unit tests

testAjaxGetJSONP: function(t){ t.pause(); - $.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?', function(data){ + $.getJSON('fixtures/jsonp.js?jsoncallback=?×tamp='+(+new Date), function(data){ t.resume(function(){ - this.assertEqual(data.items.length, 20); + this.assertEqual(data.items.length, 0); }); }); }, diff --git a/test/fixtures/jsonp.js b/test/fixtures/jsonp.js new file mode 100644 index 000000000..ae0884e38 --- /dev/null +++ b/test/fixtures/jsonp.js @@ -0,0 +1 @@ +jsonp1({"items":[]}) \ No newline at end of file