WICKET-4606 dynamic extra parameter gets used/executed even when ajaxcallistener is preconditioned to false
Add a unit test that verifies that the dynamic extra parameters are used for the Ajax call Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/8d2f63ec Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/8d2f63ec Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/8d2f63ec Branch: refs/heads/master Commit: 8d2f63ec0be9a7c8ac6a22d955a384ef1c4f0799 Parents: aa46135 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Wed Jun 13 16:43:53 2012 +0300 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Wed Jun 13 16:43:53 2012 +0300 ---------------------------------------------------------------------- wicket-core/src/test/js/ajax.js | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/8d2f63ec/wicket-core/src/test/js/ajax.js ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/js/ajax.js b/wicket-core/src/test/js/ajax.js index 6df8a00..6db63b3 100644 --- a/wicket-core/src/test/js/ajax.js +++ b/wicket-core/src/test/js/ajax.js @@ -620,5 +620,33 @@ jQuery(document).ready(function() { // fire all requests $el.triggerHandler("event1"); }); + + asyncTest('Wicket.Ajax - verify dynamic parameters are appended to the Ajax call data (GET/POST params).', function () { + + expect(5); + + var attrs = { + u: 'data/ajax/nonExisting.json', + e: 'event1', + dt: 'json', // datatype + wr: false, // not Wicket's <ajax-response> + dep: [ function() {return { "one": 1, "two": 2 } } ] + }; + + Wicket.Event.subscribe('/ajax/call/before', function(jqEvent, attributes, jqXHR, settings) { + deepEqual(attrs, attributes, 'Before: attrs'); + ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Before: Assert that jqXHR is a XMLHttpRequest'); + ok(jQuery.isFunction(settings.beforeSend), 'Before: Assert that settings is the object passed to jQuery.ajax()'); + ok(settings.url.indexOf('one=1') > 0, 'Parameter "one" with value "1" is found'); + ok(settings.url.indexOf('two=2') > 0, 'Parameter "two" with value "2" is found'); + start(); + }); + + Wicket.Ajax.ajax(attrs); + var target = jQuery(window); + target.triggerHandler("event1"); + target.off("event1"); + + }); } });
