Skip to content

Commit

Permalink
TEST added test to verify paging works with cascadePanes
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Marks committed Apr 28, 2022
1 parent 1561e20 commit 0594e2a
Showing 1 changed file with 54 additions and 33 deletions.
87 changes: 54 additions & 33 deletions test/options/searchPanes.cascadePanes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ describe('searchPanes - options - searchPanes.cascadePanes', function () {

function checkArray(pane, array) {
for (let i = 0; i < array.length; i++) {
expect($('div.dtsp-searchPane:eq(' + pane + ') table tbody tr:eq(' + i + ') td:eq(0) span.dtsp-pill').text()).toBe(
array[i].toString()
);
expect(
$('div.dtsp-searchPane:eq(' + pane + ') table tbody tr:eq(' + i + ') td:eq(0) span.dtsp-pill').text()
).toBe(array[i].toString());
}
}

Expand Down Expand Up @@ -97,7 +97,7 @@ describe('searchPanes - options - searchPanes.cascadePanes', function () {
searchPanes: {
cascadePanes: true
},
initComplete: async function () { }
initComplete: async function () {}
});

await checkRowCounts(33, 7, 33);
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('searchPanes - options - searchPanes.cascadePanes', function () {
]
}
]
},
}
});

$('div.dtsp-searchPane:visible:eq(0) tbody tr:eq(2) td:eq(0)').click();
Expand All @@ -355,32 +355,34 @@ describe('searchPanes - options - searchPanes.cascadePanes', function () {
it('Custom panes - as a button', async function () {
table = $('#example').DataTable({
dom: 'Bfrtip',
buttons: [{
extend: 'searchPanes',
config: {
cascadePanes: true,
viewTotal: true,
panes: [
{
header: 'Custom',
options: [
{
label: 'Is London?',
value: function (rowData, rowIdx) {
return rowData[2] === 'London';
}
},
{
label: 'Is New York?',
value: function (rowData, rowIdx) {
return rowData[2] === 'New York';
buttons: [
{
extend: 'searchPanes',
config: {
cascadePanes: true,
viewTotal: true,
panes: [
{
header: 'Custom',
options: [
{
label: 'Is London?',
value: function (rowData, rowIdx) {
return rowData[2] === 'London';
}
},
{
label: 'Is New York?',
value: function (rowData, rowIdx) {
return rowData[2] === 'New York';
}
}
}
]
}
]
]
}
]
}
}
}]
]
});

$('button.dt-button').click();
Expand All @@ -399,6 +401,25 @@ describe('searchPanes - options - searchPanes.cascadePanes', function () {
checkCounts(['1 (1)'], ['12 (12)'], ['1 (1)'], ['12']);
});

dt.html('basic');
it('Select item in pane so table pagination present', function () {
table = $('#example').DataTable({
dom: 'Pfrtip',
searchPanes: {
cascadePanes: true
}
});

$('div.dtsp-searchPane:visible:eq(1) tbody tr:eq(1) td:eq(0)').click();

expect($('table#example tbody td:eq(0)').text()).toBe('Angelica Ramos');
});
it('... paging still works', function () {
$('.dataTables_paginate span .paginate_button:eq(1)').click();

expect($('table#example tbody td:eq(0)').text()).toBe('Tatyana Fitzpatrick');
});

dt.html('basic');
it('SaveState and cascadePanes', async function () {
table = $('#example').DataTable({
Expand Down Expand Up @@ -447,9 +468,9 @@ describe('searchPanes - options - searchPanes.cascadePanes', function () {
extend: 'searchPanes',
config: {
cascadePanes: true
},
}
}
],
]
});

$('button.dt-button').click();
Expand All @@ -469,9 +490,9 @@ describe('searchPanes - options - searchPanes.cascadePanes', function () {
extend: 'searchPanes',
config: {
cascadePanes: true
},
}
}
],
]
});

$('button.dt-button').click();
Expand Down

0 comments on commit 0594e2a

Please sign in to comment.