annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/fnInitComplete.js @ 7:0f2b740536fb draft

Uploaded
author saskia-hiltemann
date Mon, 21 Aug 2017 09:16:07 -0400
parents ac5f9272033b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 // DATA_TEMPLATE: empty_table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 oTest.fnStart( "fnInitComplete" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 /* Fairly boring function compared to the others! */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 /* Check the default */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 "bDeferRender": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 var oSettings = oTable.fnSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 var mPass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 "Default should be null",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 function () { return oSettings.fnInitComplete == null; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 "Two arguments passed (for Ajax!)",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 mPass = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 "fnInitComplete": function ( ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 mPass = arguments.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 function () { return mPass == 2; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 "That one argument is the settings object",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 "fnInitComplete": function ( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 mPass = oSettings;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 function () { return oTable.fnSettings() == mPass; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 "fnInitComplete called once on first draw",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 mPass = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 "fnInitComplete": function ( ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 mPass++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 function () { return mPass == 1; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 "fnInitComplete never called there after",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 $('#example_next').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 $('#example_next').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 $('#example_next').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 function () { return mPass == 1; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 "10 rows in the table on complete",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 mPass = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 "fnInitComplete": function ( ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 mPass = $('#example tbody tr').length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 function () { return mPass == 10; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104 oTest.fnComplete();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 } );