Debian Codegraph @

old-tests/tests_onhold/4_server-side/bInfiniteScroll.js

raw
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "bInfiniteScroll" );
3
4
5 $(document).ready( function () {
6 var oTable = $('#example').dataTable( {
7 "bScrollInfinite": true,
8 "sScrollY": "200px",
9 "bServerSide": true,
10 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php"
11 } );
12
13 oTest.fnWaitTest(
14 "10 rows by default",
15 null,
16 function () { return $('#example tbody tr').length == 10; }
17 );
18
19 oTest.fnTest(
20 "Info",
21 null,
22 function () { return $('#example_info').html() == "Showing 1 to 10 of 57 entries"; }
23 );
24
25 oTest.fnTest(
26 "Get nodes",
27 null,
28 function () { return $('#example tbody>tr').length == 10; }
29 );
30
31 oTest.fnTest(
32 "Get nodes function",
33 null,
34 function () { return $('#example').dataTable().fnGetNodes().length == 10; }
35 );
36
37 oTest.fnWaitTest(
38 "Scroll on 20px adds 10 rows",
39 function () { $('div.dataTables_scrollBody').scrollTop(20); },
40 function () { return $('#example tbody tr').length == 20; }
41 );
42
43 oTest.fnTest(
44 "Info after 20px scroll",
45 null,
46 function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; }
47 );
48
49 oTest.fnTest(
50 "Get nodes after 20px scroll",
51 null,
52 function () { return $('#example tbody>tr').length == 20; }
53 );
54
55 oTest.fnTest(
56 "Get nodes function after 20px scroll",
57 null,
58 function () { return $('#example').dataTable().fnGetNodes().length == 20; }
59 );
60
61 oTest.fnWaitTest(
62 "Scroll on 10px more results in the same number of rows",
63 function () { $('div.dataTables_scrollBody').scrollTop(30); },
64 function () { return $('#example tbody tr').length == 20; }
65 );
66
67 oTest.fnTest(
68 "Info after 10 more px scroll",
69 null,
70 function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; }
71 );
72
73 oTest.fnWaitTest(
74 "Scroll to 280px adds another 10 rows",
75 function () { $('div.dataTables_scrollBody').scrollTop(280); },
76 function () { return $('#example tbody tr').length == 30; }
77 );
78
79 oTest.fnTest(
80 "Info after 240px scroll",
81 null,
82 function () { return $('#example_info').html() == "Showing 1 to 30 of 57 entries"; }
83 );
84
85 oTest.fnTest(
86 "Get nodes after 240px scroll",
87 null,
88 function () { return $('#example tbody>tr').length == 30; }
89 );
90
91 oTest.fnTest(
92 "Get nodes function after 240px scroll",
93 null,
94 function () { return $('#example').dataTable().fnGetNodes().length == 30; }
95 );
96
97 oTest.fnWaitTest(
98 "Filtering will drop back to 10 rows",
99 function () { oTable.fnFilter('gec') },
100 function () { return $('#example tbody tr').length == 10; }
101 );
102
103 oTest.fnTest(
104 "Info after filtering",
105 null,
106 function () { return $('#example_info').html() == "Showing 1 to 10 of 20 entries (filtered from 57 total entries)"; }
107 );
108
109 oTest.fnTest(
110 "Get nodes after filtering",
111 null,
112 function () { return $('#example tbody>tr').length == 10; }
113 );
114
115 oTest.fnTest(
116 "Get nodes function after filtering",
117 null,
118 function () { return $('#example').dataTable().fnGetNodes().length == 10; }
119 );
120
121 oTest.fnWaitTest(
122 "Scroll after filtering adds 10",
123 function () { $('div.dataTables_scrollBody').scrollTop(20); },
124 function () { return $('#example tbody tr').length == 20; }
125 );
126
127 oTest.fnWaitTest(
128 "Get nodes after filtering",
129 null,
130 function () { return $('#example tbody>tr').length == 20; }
131 );
132
133 oTest.fnWaitTest(
134 "Get nodes function after filtering",
135 null,
136 function () { return $('#example').dataTable().fnGetNodes().length == 20; }
137 );
138
139 oTest.fnWaitTest(
140 "Sorting will drop back to 10 rows",
141 function () {
142 $('div.dataTables_scrollBody').scrollTop(0);
143 oTable.fnSort([[1,'asc']])
144 },
145 function () { return $('#example tbody tr').length == 10; }
146 );
147
148 oTest.fnWaitTest(
149 "Scroll after sorting adds 10",
150 function () { $('div.dataTables_scrollBody').scrollTop(20); },
151 function () { return $('#example tbody tr').length == 20; }
152 );
153
154 oTest.fnTest(
155 "Get nodes after scrolling",
156 null,
157 function () { return $('#example tbody>tr').length == 20; }
158 );
159
160 oTest.fnTest(
161 "Get nodes function after scrolling",
162 null,
163 function () { return $('#example').dataTable().fnGetNodes().length == 20; }
164 );
165
166
167 oTest.fnComplete();
168 } );