Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HeuristicLabWeb.PluginHost/HLWebPluginHost/Content/jQuery/jQueryPlugins/DataTables-1.7.6/media/unit_testing/tests_onhold/3_ajax/sPaginationType.js @ 6286

Last change on this file since 6286 was 6286, checked in by dkahn, 13 years ago

#1198 Added jQuery plus plugins

File size: 3.1 KB
RevLine 
[6286]1// DATA_TEMPLATE: empty_table
2oTest.fnStart( "sPaginationType" );
3
4$(document).ready( function () {
5  /* Check the default */
6  var oTable = $('#example').dataTable( {
7    "sAjaxSource": "../../../examples/examples_support/json_source.txt"
8  } );
9  var oSettings = oTable.fnSettings();
10 
11  oTest.fnWaitTest(
12    "Check two button paging is the default",
13    null,
14    function () { return oSettings.sPaginationType == "two_button"; }
15  );
16 
17  oTest.fnWaitTest(
18    "Check class is applied",
19    null,
20    function () { return $('#example_paginate').hasClass('paging_two_button'); }
21  );
22 
23  oTest.fnWaitTest(
24    "Two div elements are in the wrapper",
25    null,
26    function () { return $('#example_paginate div').length == 2; }
27  );
28 
29  oTest.fnWaitTest(
30    "We have the previous button",
31    null,
32    function () { return document.getElementById('example_previous'); }
33  );
34 
35  oTest.fnWaitTest(
36    "We have the next button",
37    null,
38    function () { return document.getElementById('example_next'); }
39  );
40 
41  oTest.fnWaitTest(
42    "Previous button is disabled",
43    null,
44    function () { return $('#example_previous').hasClass('paginate_disabled_previous'); }
45  );
46 
47  oTest.fnWaitTest(
48    "Next button is enabled",
49    null,
50    function () { return $('#example_next').hasClass('paginate_enabled_next'); }
51  );
52 
53  /* Don't test paging - that's done by the zero config test script. */
54 
55 
56  /* Two buttons paging */
57  var bComplete = false;
58  oTest.fnWaitTest(
59    "Can enabled full numbers paging",
60    function () {
61      oSession.fnRestore();
62      oTable = $('#example').dataTable( {
63        "sAjaxSource": "../../../examples/examples_support/json_source.txt",
64        "sPaginationType": "full_numbers",
65        "fnInitComplete": function () {
66          bComplete = true;
67        }
68      } );
69      oSettings = oTable.fnSettings();
70    },
71    function () {
72      if ( bComplete )
73        return oSettings.sPaginationType == "full_numbers";
74      else
75        return false;
76    }
77  );
78 
79  oTest.fnWaitTest(
80    "Check full numbers class is applied",
81    null,
82    function () { return $('#example_paginate').hasClass('paging_full_numbers'); }
83  );
84 
85 
86  var nFirst, nPrevious, nNext, nLast;
87  oTest.fnWaitTest(
88    "Jump to last page",
89    function () {
90      nFirst = $('div.dataTables_paginate span.first');
91      nPrevious = $('div.dataTables_paginate span.previous');
92      nNext = $('div.dataTables_paginate span.next');
93      nLast = $('div.dataTables_paginate span.last');
94      nLast.click();
95    },
96    function () {
97      return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries";
98    }
99  );
100 
101  oTest.fnWaitTest(
102    "Go to two pages previous",
103    function () {
104      nPrevious.click();
105      nPrevious.click();
106    },
107    function () {
108      return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries";
109    }
110  );
111 
112  oTest.fnWaitTest(
113    "Next (second last) page",
114    function () {
115      nNext.click();
116    },
117    function () {
118      return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries";
119    }
120  );
121 
122  oTest.fnWaitTest(
123    "Jump to first page",
124    function () {
125      nFirst.click();
126    },
127    function () {
128      return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries";
129    }
130  );
131 
132 
133  oTest.fnComplete();
134} );
Note: See TracBrowser for help on using the repository browser.