/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/4_server-side/iDeferLoading.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/4_server-side/iDeferLoading.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 3 months ago) by torben
File MIME type: application/javascript
File size: 2270 byte(s)
initial import
1 // DATA_TEMPLATE: deferred_table
2 /*
3 */
4 oTest.fnStart( "Defer loading tests" );
5
6 $(document).ready( function () {
7 var gotServerData = false;
8
9 $('#example').dataTable( {
10 "iDeferLoading": 57,
11 "bServerSide": true,
12 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
13 "fnServerData": function (url, data, fn) {
14 $.ajax( {
15 "url": url,
16 "data": data,
17 "success": function(json) {
18 gotServerData = true;
19 fn( json );
20 },
21 "dataType": "json",
22 "cache": false
23 } );
24 }
25 } );
26
27 oTest.fnWaitTest(
28 "10 rows shown on the first page",
29 null,
30 function () { return $('#example tbody tr').length == 10; }
31 );
32
33 oTest.fnWaitTest(
34 "No request to the server yet",
35 null,
36 function () { return !gotServerData; }
37 );
38
39 oTest.fnTest(
40 "Information on zero config",
41 null,
42 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
43 );
44
45 oTest.fnWaitTest(
46 "Initial data order retained",
47 null,
48 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
49 );
50
51 oTest.fnWaitTest(
52 "Initial data order retained 2",
53 null,
54 function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; }
55 );
56
57 oTest.fnWaitTest(
58 "Still no request to the server yet",
59 null,
60 function () { return !gotServerData; }
61 );
62
63 oTest.fnWaitTest(
64 "Sorting (first click) on second column",
65 function () { $('#example thead th:eq(1)').click(); },
66 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
67 );
68
69 oTest.fnWaitTest(
70 "Now we've had a request",
71 null,
72 function () { return gotServerData; }
73 );
74
75 oTest.fnTest(
76 "Information after sort",
77 null,
78 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
79 );
80
81 oTest.fnWaitTest(
82 "Sorting (second click) on second column",
83 function () { $('#example thead th:eq(1)').click(); },
84 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
85 );
86
87 oTest.fnWaitTest(
88 "Sorting (third click) on second column",
89 function () { $('#example thead th:eq(1)').click(); },
90 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
91 );
92
93
94 oTest.fnComplete();
95 } );

  ViewVC Help
Powered by ViewVC 1.1.20