From 25148e4fec80f57eeaa846ecb7bfd8ca46ee1fe2 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 20 Aug 2010 18:07:34 +0100 Subject: [PATCH] Fixed: The second parameter for fnServerData was being passed as null when used without server-side processing. It makes much more sense to pass an empty array - 2553 --- .../tests_onhold/3_ajax/fnServerData.js | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 media/unit_testing/tests_onhold/3_ajax/fnServerData.js diff --git a/media/unit_testing/tests_onhold/3_ajax/fnServerData.js b/media/unit_testing/tests_onhold/3_ajax/fnServerData.js new file mode 100644 index 00000000..34ae2228 --- /dev/null +++ b/media/unit_testing/tests_onhold/3_ajax/fnServerData.js @@ -0,0 +1,64 @@ +// DATA_TEMPLATE: empty_table +oTest.fnStart( "fnServerData for Ajax sourced data" ); + +$(document).ready( function () { + var mPass; + + oTest.fnTest( + "Argument length", + function () { + $('#example').dataTable( { + "sAjaxSource": "../../../examples/examples_support/json_source.txt", + "fnServerData": function () { + mPass = arguments.length; + } + } ); + }, + function () { return mPass == 3; } + ); + + oTest.fnTest( + "Url", + function () { + $('#example').dataTable( { + "bDestroy": true, + "sAjaxSource": "../../../examples/examples_support/json_source.txt", + "fnServerData": function (sUrl, aoData, fnCallback) { + mPass = sUrl == "../../../examples/examples_support/json_source.txt"; + } + } ); + }, + function () { return mPass; } + ); + + oTest.fnTest( + "Data array", + function () { + $('#example').dataTable( { + "bDestroy": true, + "sAjaxSource": "../../../examples/examples_support/json_source.txt", + "fnServerData": function (sUrl, aoData, fnCallback) { + mPass = aoData.length==0; + } + } ); + }, + function () { return mPass; } + ); + + oTest.fnTest( + "Callback function", + function () { + $('#example').dataTable( { + "bDestroy": true, + "sAjaxSource": "../../../examples/examples_support/json_source.txt", + "fnServerData": function (sUrl, aoData, fnCallback) { + mPass = typeof fnCallback == 'function'; + } + } ); + }, + function () { return mPass; } + ); + + + oTest.fnComplete(); +} ); \ No newline at end of file