Skip to content

Commit

Permalink
FIX: Updated Ajax2 and Ajax2 test cases
Browse files Browse the repository at this point in the history
Fixed Ajax2 parseArguments using wrong parameter names.
Fixed Ajax2 test cases not accounting for event data.
  • Loading branch information
Stefan Andres Charsley committed Sep 2, 2013
1 parent 4b981aa commit a578dc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/ajax2.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@
return zeptoXHR
}

// handle optional data/success arguments
function parseArguments(url, data, success, responseType) {
// handle optional data/done arguments
function parseArguments(url, data, done, responseType) {
var hasData = !$.isFunction(data)
return {
url: url,
data: hasData ? data : undefined,
success: !hasData ? data : $.isFunction(success) ? success : undefined,
responseType: hasData ? responseType || success : success
done: !hasData ? data : $.isFunction(done) ? done : undefined,
responseType: hasData ? responseType || done : done
}
}

Expand All @@ -253,7 +253,7 @@

$.getJSON = function (url, data, done) {
var options = parseArguments.apply(null, arguments)
// Not yet supported by any browsers
// Currently only supported by Firefox and Chrome dev
options.responseType = 'json'
return $.ajax(options)
}
Expand Down
10 changes: 5 additions & 5 deletions test/ajax2.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>Zepto Ajax2 unit tests</h1>
}

function resumeOnAjaxError(t) {
$(document).on('ajaxError', function (xhr, settings, e) {
$(document).on('ajaxError', function (e, xhr, settings, err) {
deferredResume(t, function () {
t.assert(false, "request errored out: " + xhr.responseText)
})
Expand Down Expand Up @@ -535,7 +535,7 @@ <h1>Zepto Ajax2 unit tests</h1>
}
}

Evidence('ZeptoAjaxTest2', {
Evidence('ZeptoAjax2Test2', {
setUp: function () {
$.ajaxSettings.xhr = function () { return new MockXHR }
},
Expand Down Expand Up @@ -718,14 +718,14 @@ <h1>Zepto Ajax2 unit tests</h1>

testGlobalBeforeSendAbort: function (t) {
var xhr
$(document).on('ajaxBeforeSend', function (x, s) { xhr = x; return false })
$(document).on('ajaxBeforeSend', function (e, x, s) { xhr = x; return false })
t.assertFalse($.ajax())
t.assert(xhr.aborted)
},

testGlobalAjaxStartCantAbort: function (t) {
var xhr
$(document).on('ajaxStart', function (x, s) { xhr = x; return false })
$(document).on('ajaxStart', function (e, x, s) { xhr = x; return false })
t.assert($.ajax())
t.assert(!xhr.aborted)
},
Expand Down Expand Up @@ -814,7 +814,7 @@ <h1>Zepto Ajax2 unit tests</h1>
}
})

Evidence('ZeptoAjaxHelperMethodsTest', {
Evidence('ZeptoAjax2HelperMethodsTest', {

testParamMethod: function (t) {
var result = $.param({ libs: ['jQuery', 'script.aculo.us', 'Prototype', 'Dojo'] })
Expand Down

0 comments on commit a578dc9

Please sign in to comment.