/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/5_ajax_objects/fnDrawCallback.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/5_ajax_objects/fnDrawCallback.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: 3049 byte(s)
initial import
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "fnDrawCallback" );
3
4 /* Fairly boring function compared to the others! */
5
6 $(document).ready( function () {
7 /* Check the default */
8 var oTable = $('#example').dataTable( {
9 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
10 "aoColumns": [
11 { "mData": "engine" },
12 { "mData": "browser" },
13 { "mData": "platform" },
14 { "mData": "version" },
15 { "mData": "grade" }
16 ]
17 } );
18 var oSettings = oTable.fnSettings();
19 var mPass, bInit;
20
21 oTest.fnWaitTest(
22 "Default should be null",
23 null,
24 function () { return oSettings.fnDrawCallback == null; }
25 );
26
27
28 oTest.fnWaitTest(
29 "One argument passed",
30 function () {
31 oSession.fnRestore();
32
33 mPass = -1;
34 bInit = false;
35 $('#example').dataTable( {
36 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
37 "aoColumnDefs": [
38 { "mData": "engine", "aTargets": [0] },
39 { "mData": "browser", "aTargets": [1] },
40 { "mData": "platform", "aTargets": [2] },
41 { "mData": "version", "aTargets": [3] },
42 { "mData": "grade", "aTargets": [4] }
43 ],
44 "fnDrawCallback": function ( ) {
45 mPass = arguments.length;
46 },
47 "fnInitComplete": function () {
48 bInit = true;
49 }
50 } );
51 },
52 function () { return mPass == 1 && bInit; }
53 );
54
55
56 oTest.fnWaitTest(
57 "That one argument is the settings object",
58 function () {
59 oSession.fnRestore();
60
61 bInit = false;
62 oTable = $('#example').dataTable( {
63 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
64 "aoColumnDefs": [
65 { "mData": "engine", "aTargets": [0] },
66 { "mData": "browser", "aTargets": [1] },
67 { "mData": "platform", "aTargets": [2] },
68 { "mData": "version", "aTargets": [3] },
69 { "mData": "grade", "aTargets": [4] }
70 ],
71 "fnDrawCallback": function ( oSettings ) {
72 mPass = oSettings;
73 },
74 "fnInitComplete": function () {
75 bInit = true;
76 }
77 } );
78 },
79 function () { return oTable.fnSettings() == mPass && bInit; }
80 );
81
82
83 /* The draw callback is called once for the init and then when the data is added */
84 oTest.fnWaitTest(
85 "fnRowCallback called once on first draw",
86 function () {
87 oSession.fnRestore();
88
89 mPass = 0;
90 bInit = false;
91 $('#example').dataTable( {
92 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
93 "aoColumnDefs": [
94 { "mData": "engine", "aTargets": [0] },
95 { "mData": "browser", "aTargets": [1] },
96 { "mData": "platform", "aTargets": [2] },
97 { "mData": "version", "aTargets": [3] },
98 { "mData": "grade", "aTargets": [4] }
99 ],
100 "fnDrawCallback": function ( ) {
101 mPass++;
102 },
103 "fnInitComplete": function () {
104 bInit = true;
105 }
106 } );
107 },
108 function () { return mPass == 2 && bInit; }
109 );
110
111 oTest.fnWaitTest(
112 "fnRowCallback called once on each draw there after as well",
113 function () {
114 $('#example_next').click();
115 $('#example_next').click();
116 $('#example_next').click();
117 },
118 function () { return mPass == 5; }
119 );
120
121
122
123
124
125 oTest.fnComplete();
126 } );

  ViewVC Help
Powered by ViewVC 1.1.20