/app/webroot/js/dataTables-1.6/media/unit_testing/tests_onhold/1_dom/sPaginationType.js

https://bitbucket.org/unsl/listop · JavaScript · 122 lines · 99 code · 19 blank · 4 comment · 7 complexity · a599061bc78f0b5ba7c6764857feae32 MD5 · raw file

  1. // DATA_TEMPLATE: dom_data
  2. oTest.fnStart( "sPaginationType" );
  3. $(document).ready( function () {
  4. /* Check the default */
  5. var oTable = $('#example').dataTable();
  6. var oSettings = oTable.fnSettings();
  7. oTest.fnTest(
  8. "Check two button paging is the default",
  9. null,
  10. function () { return oSettings.sPaginationType == "two_button"; }
  11. );
  12. oTest.fnTest(
  13. "Check class is applied",
  14. null,
  15. function () { return $('#example_paginate').hasClass('paging_two_button'); }
  16. );
  17. oTest.fnTest(
  18. "Two div elements are in the wrapper",
  19. null,
  20. function () { return $('#example_paginate div').length == 2; }
  21. );
  22. oTest.fnTest(
  23. "We have the previous button",
  24. null,
  25. function () { return document.getElementById('example_previous'); }
  26. );
  27. oTest.fnTest(
  28. "We have the next button",
  29. null,
  30. function () { return document.getElementById('example_next'); }
  31. );
  32. oTest.fnTest(
  33. "Previous button is disabled",
  34. null,
  35. function () { return $('#example_previous').hasClass('paginate_disabled_previous'); }
  36. );
  37. oTest.fnTest(
  38. "Next button is enabled",
  39. null,
  40. function () { return $('#example_next').hasClass('paginate_enabled_next'); }
  41. );
  42. /* Don't test paging - that's done by the zero config test script. */
  43. /* Two buttons paging */
  44. oTest.fnTest(
  45. "Can enabled full numbers paging",
  46. function () {
  47. oSession.fnRestore();
  48. oTable = $('#example').dataTable( {
  49. "sPaginationType": "full_numbers"
  50. } );
  51. oSettings = oTable.fnSettings();
  52. },
  53. function () { return oSettings.sPaginationType == "full_numbers"; }
  54. );
  55. oTest.fnTest(
  56. "Check full numbers class is applied",
  57. null,
  58. function () { return $('#example_paginate').hasClass('paging_full_numbers'); }
  59. );
  60. var nFirst, nPrevious, nNext, nLast;
  61. oTest.fnTest(
  62. "Jump to last page",
  63. function () {
  64. nFirst = $('div.dataTables_paginate span.first');
  65. nPrevious = $('div.dataTables_paginate span.previous');
  66. nNext = $('div.dataTables_paginate span.next');
  67. nLast = $('div.dataTables_paginate span.last');
  68. nLast.click();
  69. },
  70. function () {
  71. return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries";
  72. }
  73. );
  74. oTest.fnTest(
  75. "Go to two pages previous",
  76. function () {
  77. nPrevious.click();
  78. nPrevious.click();
  79. },
  80. function () {
  81. return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries";
  82. }
  83. );
  84. oTest.fnTest(
  85. "Next (second last) page",
  86. function () {
  87. nNext.click();
  88. },
  89. function () {
  90. return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries";
  91. }
  92. );
  93. oTest.fnTest(
  94. "Jump to first page",
  95. function () {
  96. nFirst.click();
  97. },
  98. function () {
  99. return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries";
  100. }
  101. );
  102. oTest.fnComplete();
  103. } );