I am using Jack as JavaScript mocking library. http://github.com/keronsen/jack . I am also using qunit.
I have following AJAX call in my javascript code which I am tring to write test for.
$.ajax({
url: $('#advance_search_form').attr('action'),
type: 'post',
dataType: 'json',
data: parameterizedData,
success: function(json) {
APP.actOnResult.successCallback(json);
}
});
Following code is working.
jack(function() {
jack.expect('$.ajax').exactly('1 time');
}
However I want to test if all the arguments are properly submitted. I tried following but did not work.
jack.expect('$.ajax').exactly('1 time').whereArgument(0).is(function(){
var args = arguments; ok('http://localhost:3000/users', args.url, 'url should be valid'); // similary test for many keys of object });
I want to get hold of arguments so that I could perform a battery of test.