annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/sPaginationType.js @ 9:7300ed4c1481 draft default tip

Uploaded
author saskia-hiltemann
date Mon, 04 Sep 2017 10:49:00 -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( "sPaginationType" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 /* Check the default */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 "bDeferRender": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 var oSettings = oTable.fnSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 "Check two button paging is the default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 function () { return oSettings.sPaginationType == "two_button"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 "Check class is applied",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 function () { return $('#example_paginate').hasClass('paging_two_button'); }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 "Two A elements are in the wrapper",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 function () { return $('#example_paginate a').length == 2; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 "We have the previous button",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 function () { return document.getElementById('example_previous'); }
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 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 "We have the next button",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 function () { return document.getElementById('example_next'); }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43 "Previous button is disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 function () { return $('#example_previous').hasClass('paginate_disabled_previous'); }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 "Next button is enabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 function () { return $('#example_next').hasClass('paginate_enabled_next'); }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 /* Don't test paging - that's done by the zero config test script. */
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 /* Two buttons paging */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 var bComplete = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 "Can enabled full numbers paging",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 oTable = $('#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 "sPaginationType": "full_numbers",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 "fnInitComplete": function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 bComplete = true;
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 oSettings = oTable.fnSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 if ( bComplete )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 return oSettings.sPaginationType == "full_numbers";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 "Check full numbers class is applied",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 function () { return $('#example_paginate').hasClass('paging_full_numbers'); }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 var nFirst, nPrevious, nNext, nLast;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 "Jump to last page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 nFirst = $('div.dataTables_paginate a.first');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 nPrevious = $('div.dataTables_paginate a.previous');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 nNext = $('div.dataTables_paginate a.next');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 nLast = $('div.dataTables_paginate a.last');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96 nLast.click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries";
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 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104 "Go to two pages previous",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106 nPrevious.click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 nPrevious.click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110 return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
113
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
114 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
115 "Next (second last) page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
116 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
117 nNext.click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
118 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
119 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
120 return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
121 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
122 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
123
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
124 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
125 "Jump to first page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
126 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
127 nFirst.click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
128 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
129 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
130 return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
131 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
132 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
133
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
134
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
135 oTest.fnComplete();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
136 } );