Skip to content

Commit

Permalink
Add test for tables that have multiple tbodies and associated theads.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeWannacott committed May 26, 2023
1 parent 38a0662 commit 5fe0fcb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/missingTableTags.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
require("iconv-lite").encodingExists("foo");
const tableSortJs = require("../public/table-sort");

function createTestTableNoMissingTags(testTableData, classTags = "") {
Expand Down Expand Up @@ -30,7 +31,7 @@ function createTestTableNoMissingTags(testTableData, classTags = "") {
</html>`);

// Call tablesort and make table sortable and simulate click from a user.
tableSortJs(true, tableWithHeadAndBody.window.document);
tableSortJs((testing = true), tableWithHeadAndBody.window.document);
tableWithHeadAndBody.window.document.querySelector("table th").click();
// Make an array from table contents to test if sorted correctly.
let table = tableWithHeadAndBody.window.document.querySelector("table");
Expand Down Expand Up @@ -68,7 +69,7 @@ function createTestTableMissingHeadTag(testTableData, classTags = "") {
</html>`);

// Call tablesort and make table sortable and simulate click from a user.
tableSortJs(true, tableWithMissingHeadTag.window.document);
tableSortJs((testing = true), tableWithMissingHeadTag.window.document);
tableWithMissingHeadTag.window.document.querySelector("table th").click();
// Make an array from table contents to test if sorted correctly.
let table = tableWithMissingHeadTag.window.document.querySelector("table");
Expand Down Expand Up @@ -106,7 +107,7 @@ function createTestTableMissingBodyTag(testTableData, classTags = "") {
</html>`);

// Call tablesort and make table sortable and simulate click from a user.
tableSortJs(tablewithMissingBodyTag.window.document);
tableSortJs((testing = true), tablewithMissingBodyTag.window.document);
tablewithMissingBodyTag.window.document.querySelector("table th").click();
// Make an array from table contents to test if sorted correctly.
let table = tablewithMissingBodyTag.window.document.querySelector("table");
Expand Down Expand Up @@ -142,7 +143,7 @@ function createTestTableMissingBodyAndHeadTag(testTableData, classTags = "") {
</html>`);

// Call tablesort and make table sortable and simulate click from a user.
tableSortJs(true, tableWithMissingBodyAndHeadTag.window.document);
tableSortJs((testing = true), tableWithMissingBodyAndHeadTag.window.document);
tableWithMissingBodyAndHeadTag.window.document
.querySelector("table th")
.click();
Expand Down Expand Up @@ -205,7 +206,7 @@ function createTestTableMultipleTBodies(
</body>
</html>`);
// Call tablesort and make table sortable and simulate click from a user.
tableSortJs(true, tableWithMultipleTableBodies.window.document);
tableSortJs((testing = true), tableWithMultipleTableBodies.window.document);
const tableTH =
tableWithMultipleTableBodies.window.document.querySelectorAll("table th");
for (let th of tableTH) {
Expand Down

0 comments on commit 5fe0fcb

Please sign in to comment.