/datatables/media/unit_testing/tests_onhold/5_ajax_objects/aoColumns.bVisible.js

https://bitbucket.org/subhan_12/dlp · JavaScript · 131 lines · 116 code · 13 blank · 2 comment · 17 complexity · a97bf538707e8151c7ae9512663959e5 MD5 · raw file

  1. // DATA_TEMPLATE: empty_table
  2. oTest.fnStart( "aoColumns.bVisible" );
  3. $(document).ready( function () {
  4. /* Check the default */
  5. var oTable = $('#example').dataTable( {
  6. "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
  7. "aoColumns": [
  8. { "mData": "engine" },
  9. { "mData": "browser" },
  10. { "mData": "platform" },
  11. { "mData": "version" },
  12. { "mData": "grade" }
  13. ]
  14. } );
  15. var oSettings = oTable.fnSettings();
  16. oTest.fnWaitTest(
  17. "All columns are visible by default",
  18. null,
  19. function () { return $('#example tbody tr:eq(0) td').length == 5; }
  20. );
  21. oTest.fnWaitTest(
  22. "Can hide one column and it removes td column from DOM",
  23. function () {
  24. oSession.fnRestore();
  25. $('#example').dataTable( {
  26. "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
  27. "aoColumns": [
  28. { "mData": "engine" },
  29. { "mData": "browser", "bVisible": false },
  30. { "mData": "platform" },
  31. { "mData": "version" },
  32. { "mData": "grade" }
  33. ]
  34. } );
  35. },
  36. function () { return $('#example tbody tr:eq(0) td').length == 4; }
  37. );
  38. oTest.fnWaitTest(
  39. "Can hide one column and it removes thead th column from DOM",
  40. null,
  41. function () { return $('#example thead tr:eq(0) th').length == 4; }
  42. );
  43. oTest.fnWaitTest(
  44. "The correct thead column has been hidden",
  45. null,
  46. function () {
  47. var jqNodes = $('#example thead tr:eq(0) th');
  48. var bReturn =
  49. jqNodes[0].innerHTML == "Rendering engine" &&
  50. jqNodes[1].innerHTML == "Platform(s)" &&
  51. jqNodes[2].innerHTML == "Engine version" &&
  52. jqNodes[3].innerHTML == "CSS grade";
  53. return bReturn;
  54. }
  55. );
  56. oTest.fnWaitTest(
  57. "The correct tbody column has been hidden",
  58. function () {
  59. oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } );
  60. },
  61. function () {
  62. var jqNodes = $('#example tbody tr:eq(0) td');
  63. var bReturn =
  64. jqNodes[0].innerHTML == "Gecko" &&
  65. jqNodes[1].innerHTML == "Gnome" &&
  66. jqNodes[2].innerHTML == "1.8" &&
  67. jqNodes[3].innerHTML == "A";
  68. return bReturn;
  69. }
  70. );
  71. oTest.fnWaitTest(
  72. "Can hide multiple columns and it removes td column from DOM",
  73. function () {
  74. oSession.fnRestore();
  75. $('#example').dataTable( {
  76. "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
  77. "aoColumns": [
  78. { "mData": "engine" },
  79. { "mData": "browser", "bVisible": false },
  80. { "mData": "platform", "bVisible": false },
  81. { "mData": "version" },
  82. { "mData": "grade", "bVisible": false }
  83. ]
  84. } );
  85. },
  86. function () { return $('#example tbody tr:eq(0) td').length == 2; }
  87. );
  88. oTest.fnWaitTest(
  89. "Multiple hide - removes thead th column from DOM",
  90. null,
  91. function () { return $('#example thead tr:eq(0) th').length == 2; }
  92. );
  93. oTest.fnWaitTest(
  94. "Multiple hide - the correct thead columns have been hidden",
  95. null,
  96. function () {
  97. var jqNodes = $('#example thead tr:eq(0) th');
  98. var bReturn =
  99. jqNodes[0].innerHTML == "Rendering engine" &&
  100. jqNodes[1].innerHTML == "Engine version"
  101. return bReturn;
  102. }
  103. );
  104. oTest.fnWaitTest(
  105. "Multiple hide - the correct tbody columns have been hidden",
  106. function () {
  107. oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } );
  108. },
  109. function () {
  110. var jqNodes = $('#example tbody tr:eq(0) td');
  111. var bReturn =
  112. jqNodes[0].innerHTML == "Gecko" &&
  113. jqNodes[1].innerHTML == "1"
  114. return bReturn;
  115. }
  116. );
  117. oTest.fnComplete();
  118. } );