mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-19 17:54:14 +01:00
New: Creation of TR/TD elements when using an Ajax or JS source for the table can be defered until draw time, when the rows are actually needed now - 4739. This is enabled by setting bDeferRender to true at initialisation time. It provides major benefits for speed in IE when dealing with large tables. However do note that if you are using fnGetNodes() with this enabled, then you will only get nodes which have been rendered.
New: Unit tests for delayed rendering. Now up to 2500+ unit tests :-)
This commit is contained in:
parent
2d0aff2b39
commit
dbc8046e6b
280
media/js/jquery.dataTables.js
vendored
280
media/js/jquery.dataTables.js
vendored
@ -914,7 +914,8 @@
|
||||
"bProcessing": false,
|
||||
"bSortClasses": true,
|
||||
"bStateSave": false,
|
||||
"bServerSide": false
|
||||
"bServerSide": false,
|
||||
"bDeferRender": false
|
||||
};
|
||||
|
||||
/*
|
||||
@ -2026,8 +2027,11 @@
|
||||
{
|
||||
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
||||
{
|
||||
nTd = oSettings.aoData[i]._anHidden[iCol];
|
||||
oSettings.aoData[i].nTr.appendChild( nTd );
|
||||
if ( oSettings.aoData[i].nTr !== null )
|
||||
{
|
||||
nTd = oSettings.aoData[i]._anHidden[iCol];
|
||||
oSettings.aoData[i].nTr.appendChild( nTd );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2046,9 +2050,12 @@
|
||||
anTds = _fnGetTdNodes( oSettings );
|
||||
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
||||
{
|
||||
nTd = oSettings.aoData[i]._anHidden[iCol];
|
||||
oSettings.aoData[i].nTr.insertBefore( nTd, $('>td:eq('+iBefore+')',
|
||||
oSettings.aoData[i].nTr)[0] );
|
||||
if ( oSettings.aoData[i].nTr !== null )
|
||||
{
|
||||
nTd = oSettings.aoData[i]._anHidden[iCol];
|
||||
oSettings.aoData[i].nTr.insertBefore( nTd, $('>td:eq('+iBefore+')',
|
||||
oSettings.aoData[i].nTr)[0] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2058,9 +2065,12 @@
|
||||
anTds = _fnGetTdNodes( oSettings );
|
||||
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
||||
{
|
||||
nTd = anTds[ ( i*oSettings.aoColumns.length) + (iCol*1) ];
|
||||
oSettings.aoData[i]._anHidden[iCol] = nTd;
|
||||
nTd.parentNode.removeChild( nTd );
|
||||
if ( oSettings.aoData[i].nTr !== null )
|
||||
{
|
||||
nTd = anTds[ ( i*oSettings.aoColumns.length) + (iCol*1) ];
|
||||
oSettings.aoData[i]._anHidden[iCol] = nTd;
|
||||
nTd.parentNode.removeChild( nTd );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2187,7 +2197,10 @@
|
||||
nOrig.appendChild( oSettings.nTable );
|
||||
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
||||
{
|
||||
nBody.appendChild( oSettings.aoData[i].nTr );
|
||||
if ( oSettings.aoData[i].nTr !== null )
|
||||
{
|
||||
nBody.appendChild( oSettings.aoData[i].nTr );
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore the width of the original table */
|
||||
@ -2608,7 +2621,7 @@
|
||||
/* Create the object for storing information about this new row */
|
||||
var iRow = oSettings.aoData.length;
|
||||
var oData = {
|
||||
"nTr": document.createElement('tr'),
|
||||
"nTr": null,//xxx document.createElement('tr'),
|
||||
"_iId": oSettings.iNextId++,
|
||||
"_aData": aDataIn,
|
||||
"_anHidden": [],
|
||||
@ -2629,36 +2642,19 @@
|
||||
|
||||
/* Create the cells */
|
||||
var nTd, sThisType;
|
||||
for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
|
||||
for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
var oCol = oSettings.aoColumns[i];
|
||||
nTd = document.createElement('td');
|
||||
|
||||
/* Pre-render if needed */
|
||||
if ( typeof oCol.fnRender == 'function' )
|
||||
/* Use rendered data for filtering/sorting */
|
||||
if ( typeof oCol.fnRender == 'function' && oCol.bUseRendered )
|
||||
{
|
||||
var sRendered = oCol.fnRender( {
|
||||
_fnSetCellData( oSettings, iRow, i, oCol.fnRender( {
|
||||
"iDataRow": iRow,
|
||||
"iDataColumn": i,
|
||||
"aData": aDataIn,
|
||||
"aData": oData._aData,
|
||||
"oSettings": oSettings
|
||||
} );
|
||||
nTd.innerHTML = sRendered;
|
||||
if ( oCol.bUseRendered )
|
||||
{
|
||||
/* Use the rendered data for filtering/sorting */
|
||||
_fnSetCellData( oSettings, iRow, i, sRendered );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, '' );
|
||||
}
|
||||
|
||||
/* Add user defined class */
|
||||
if ( oCol.sClass !== null )
|
||||
{
|
||||
nTd.className = oCol.sClass;
|
||||
} ) );
|
||||
}
|
||||
|
||||
/* See if we should auto-detect the column type */
|
||||
@ -2676,22 +2672,67 @@
|
||||
oCol.sType = 'string';
|
||||
}
|
||||
}
|
||||
|
||||
if ( oCol.bVisible )
|
||||
{
|
||||
oData.nTr.appendChild( nTd );
|
||||
oData._anHidden[i] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
oData._anHidden[i] = nTd;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add to the display array */
|
||||
oSettings.aiDisplayMaster.push( iRow );
|
||||
|
||||
/* Create the DOM imformation */
|
||||
if ( !oSettings.oFeatures.bDeferRender )
|
||||
{
|
||||
_fnCreateTr( oSettings, iRow );
|
||||
}
|
||||
|
||||
return iRow;
|
||||
}
|
||||
|
||||
function _fnCreateTr ( oSettings, iRow )
|
||||
{
|
||||
var oData = oSettings.aoData[iRow];
|
||||
var nTd;
|
||||
|
||||
if ( oData.nTr === null )
|
||||
{
|
||||
oData.nTr = document.createElement('tr');
|
||||
|
||||
for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
var oCol = oSettings.aoColumns[i];
|
||||
nTd = document.createElement('td');
|
||||
|
||||
/* Render if needed */
|
||||
if ( typeof oCol.fnRender == 'function' )
|
||||
{
|
||||
nTd.innerHTML = oCol.fnRender( {
|
||||
"iDataRow": iRow,
|
||||
"iDataColumn": i,
|
||||
"aData": oData._aData,
|
||||
"oSettings": oSettings
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, '' );
|
||||
}
|
||||
|
||||
/* Add user defined class */
|
||||
if ( oCol.sClass !== null )
|
||||
{
|
||||
nTd.className = oCol.sClass;
|
||||
}
|
||||
|
||||
if ( oCol.bVisible )
|
||||
{
|
||||
oData.nTr.appendChild( nTd );
|
||||
oData._anHidden[i] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
oData._anHidden[i] = nTd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _fnGatherData
|
||||
@ -3109,6 +3150,12 @@
|
||||
for ( var j=iStart ; j<iEnd ; j++ )
|
||||
{
|
||||
var aoData = oSettings.aoData[ oSettings.aiDisplay[j] ];
|
||||
if ( aoData.nTr === null )
|
||||
{
|
||||
_fnCreateTr( oSettings, oSettings.aiDisplay[j] );
|
||||
bNewRowCreated = true;
|
||||
}
|
||||
|
||||
var nRow = aoData.nTr;
|
||||
|
||||
/* Remove the old stripping classes and then add the new one */
|
||||
@ -4487,7 +4534,7 @@
|
||||
}
|
||||
|
||||
/* Alter the sorting classes to take account of the changes */
|
||||
if ( typeof bApplyClasses == 'undefined' || bApplyClasses )
|
||||
if ( (typeof bApplyClasses == 'undefined' || bApplyClasses) && !oSettings.oFeatures.bDeferRender )
|
||||
{
|
||||
_fnSortingClasses( oSettings );
|
||||
}
|
||||
@ -4720,15 +4767,22 @@
|
||||
* Further to this, note that this code is admitadly fairly ugly. It could be made a lot
|
||||
* simpiler using jQuery selectors and add/removeClass, but that is significantly slower
|
||||
* (on the order of 5 times slower) - hence the direct DOM manipulation here.
|
||||
* Note that for defered drawing we do use jQuery - the reason being that taking the first
|
||||
* row found to see if the whole column needs processed can miss classes since the first
|
||||
* column might be new.
|
||||
*/
|
||||
sClass = oClasses.sSortColumn;
|
||||
|
||||
if ( oSettings.oFeatures.bSort && oSettings.oFeatures.bSortClasses )
|
||||
{
|
||||
var nTds = _fnGetTdNodes( oSettings );
|
||||
|
||||
|
||||
/* Remove the old classes */
|
||||
if ( nTds.length >= iColumns )
|
||||
if ( oSettings.oFeatures.bDeferRender )
|
||||
{
|
||||
$(nTds).removeClass(sClass+'1 '+sClass+'2 '+sClass+'3');
|
||||
}
|
||||
else if ( nTds.length >= iColumns )
|
||||
{
|
||||
for ( i=0 ; i<iColumns ; i++ )
|
||||
{
|
||||
@ -5515,61 +5569,25 @@
|
||||
* Returns: string: - max strlens for each column
|
||||
* Inputs: object:oSettings - dataTables settings object
|
||||
* int:iCol - column of interest
|
||||
* boolean:bFast - Should we use fast (but non-accurate) calculation - optional,
|
||||
* default true
|
||||
* Notes: This operation is _expensive_ (!!!). It requires a lot of DOM interaction, but
|
||||
* this is the only way to reliably get the widest string. For example 'mmm' would be wider
|
||||
* than 'iiii' so we can't just ocunt characters. If this can be optimised it would be good
|
||||
* to do so!
|
||||
*/
|
||||
function _fnGetWidestNode( oSettings, iCol, bFast )
|
||||
function _fnGetWidestNode( oSettings, iCol )
|
||||
{
|
||||
/* Use fast not non-accurate calculate based on the strlen */
|
||||
if ( typeof bFast == 'undefined' || bFast )
|
||||
var iMaxIndex = _fnGetMaxLenString( oSettings, iCol );
|
||||
var iVis = _fnColumnIndexToVisible( oSettings, iCol);
|
||||
if ( iMaxIndex < 0 )
|
||||
{
|
||||
var iMaxLen = _fnGetMaxLenString( oSettings, iCol );
|
||||
var iFastVis = _fnColumnIndexToVisible( oSettings, iCol);
|
||||
if ( iMaxLen < 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return oSettings.aoData[iMaxLen].nTr.getElementsByTagName('td')[iFastVis];
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Use the slow approach, but get high quality answers - note that this code is not actually
|
||||
* used by DataTables by default. If you want to use it you can alter the call to
|
||||
* _fnGetWidestNode to pass 'false' as the third argument
|
||||
*/
|
||||
var
|
||||
iMax = -1, i, iLen,
|
||||
iMaxIndex = -1,
|
||||
n = document.createElement('div');
|
||||
|
||||
n.style.visibility = "hidden";
|
||||
n.style.position = "absolute";
|
||||
document.body.appendChild( n );
|
||||
|
||||
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
||||
|
||||
if ( oSettings.aoData[iMaxIndex].nTr === null )
|
||||
{
|
||||
n.innerHTML = _fnGetCellData( oSettings, i, iCol, '' );
|
||||
if ( n.offsetWidth > iMax )
|
||||
{
|
||||
iMax = n.offsetWidth;
|
||||
iMaxIndex = i;
|
||||
}
|
||||
var n = document.createElement('td');
|
||||
n.appendChild( document.createTextNode(
|
||||
_fnGetCellData( oSettings, iMaxIndex, iCol, '' ) )
|
||||
);
|
||||
return n;
|
||||
}
|
||||
document.body.removeChild( n );
|
||||
|
||||
if ( iMaxIndex >= 0 )
|
||||
{
|
||||
var iVis = _fnColumnIndexToVisible( oSettings, iCol);
|
||||
var nRet = oSettings.aoData[iMaxIndex].nTr.getElementsByTagName('td')[iVis];
|
||||
if ( nRet )
|
||||
{
|
||||
return nRet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return oSettings.aoData[iMaxIndex].nTr.getElementsByTagName('td')[iVis];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5724,54 +5742,61 @@
|
||||
function _fnGetTrNodes ( oSettings )
|
||||
{
|
||||
var aNodes = [];
|
||||
var iLen = oSettings.aoData.length;
|
||||
for ( var i=0 ; i<iLen ; i++ )
|
||||
for ( var i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
||||
{
|
||||
aNodes.push( oSettings.aoData[i].nTr );
|
||||
if ( oSettings.aoData[i].nTr !== null )
|
||||
{
|
||||
aNodes.push( oSettings.aoData[i].nTr );
|
||||
}
|
||||
}
|
||||
return aNodes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _fnGetTdNodes
|
||||
* Purpose: Return an array with the TD nodes for the table
|
||||
* Purpose: Return an flat array with all TD nodes for the table
|
||||
* Returns: array: - TD array
|
||||
* Inputs: object:oSettings - dataTables settings object
|
||||
*/
|
||||
function _fnGetTdNodes ( oSettings )
|
||||
{
|
||||
var nTrs = _fnGetTrNodes( oSettings );
|
||||
var nTds = [], nTd;
|
||||
var anReturn = [];
|
||||
var iCorrector;
|
||||
var iRow, iRows, iColumn, iColumns;
|
||||
|
||||
for ( iRow=0, iRows=nTrs.length ; iRow<iRows ; iRow++ )
|
||||
var anTds;
|
||||
var iRow, iRows=oSettings.aoData.length,
|
||||
iColumn, iColumns;
|
||||
|
||||
for ( iRow=0 ; iRow<iRows ; iRow++ )
|
||||
{
|
||||
nTds = [];
|
||||
for ( iColumn=0, iColumns=nTrs[iRow].childNodes.length ; iColumn<iColumns ; iColumn++ )
|
||||
oData = oSettings.aoData[iRow];
|
||||
if ( oData.nTr !== null )
|
||||
{
|
||||
nTd = nTrs[iRow].childNodes[iColumn];
|
||||
if ( nTd.nodeName.toUpperCase() == "TD" )
|
||||
/* get the TD child nodes - taking into account text etc nodes */
|
||||
anTds = [];
|
||||
for ( iColumn=0, iColumns=oData.nTr.childNodes.length ; iColumn<iColumns ; iColumn++ )
|
||||
{
|
||||
nTds.push( nTd );
|
||||
if ( oData.nTr.childNodes[iColumn].nodeName.toLowerCase() == 'td' )
|
||||
{
|
||||
anTds.push( oData.nTr.childNodes[iColumn] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iCorrector = 0;
|
||||
for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
|
||||
{
|
||||
if ( oSettings.aoColumns[iColumn].bVisible )
|
||||
|
||||
iCorrector = 0;
|
||||
for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
|
||||
{
|
||||
anReturn.push( nTds[iColumn-iCorrector] );
|
||||
}
|
||||
else
|
||||
{
|
||||
anReturn.push( oSettings.aoData[iRow]._anHidden[iColumn] );
|
||||
iCorrector++;
|
||||
if ( oSettings.aoColumns[iColumn].bVisible )
|
||||
{
|
||||
anReturn.push( anTds[iColumn-iCorrector] );
|
||||
}
|
||||
else
|
||||
{
|
||||
anReturn.push( oData._anHidden[iColumn] );
|
||||
iCorrector++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return anReturn;
|
||||
}
|
||||
|
||||
@ -6717,6 +6742,7 @@
|
||||
_fnMap( oSettings.oFeatures, oInit, "bAutoWidth" );
|
||||
_fnMap( oSettings.oFeatures, oInit, "bSortClasses" );
|
||||
_fnMap( oSettings.oFeatures, oInit, "bServerSide" );
|
||||
_fnMap( oSettings.oFeatures, oInit, "bDeferRender" );
|
||||
_fnMap( oSettings.oScroll, oInit, "sScrollX", "sX" );
|
||||
_fnMap( oSettings.oScroll, oInit, "sScrollXInner", "sXInner" );
|
||||
_fnMap( oSettings.oScroll, oInit, "sScrollY", "sY" );
|
||||
@ -6784,6 +6810,16 @@
|
||||
"sName": "server_side_sort_classes"
|
||||
} );
|
||||
}
|
||||
else if ( oSettings.oFeatures.bDeferRender && oSettings.oFeatures.bSortClasses )
|
||||
{
|
||||
/* Enable sort classes for server-side processing. Safe to do it here, since server-side
|
||||
* processing must be enabled by the developer
|
||||
*/
|
||||
oSettings.aoDrawCallback.push( {
|
||||
"fn": _fnSortingClasses,
|
||||
"sName": "defer_sort_classes"
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof oInit.bJQueryUI != 'undefined' && oInit.bJQueryUI )
|
||||
{
|
||||
|
@ -20,9 +20,9 @@ $(document).ready( function () {
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnTest(
|
||||
"Single column - fnRender is called once for each row",
|
||||
"Single column - fnRender is called twice for each row",
|
||||
null,
|
||||
function () { return mTmp == 57; }
|
||||
function () { return mTmp == 114; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
@ -51,33 +51,6 @@ $(document).ready( function () {
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"fnRender iDataColumn is row number",
|
||||
function () {
|
||||
var iCount = 0;
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"aaData": gaaData,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( iCount != a.iDataRow )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
iCount++;
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"fnRender iDataColumn is the column",
|
||||
function () {
|
||||
|
@ -20,9 +20,9 @@ $(document).ready( function () {
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Single column - fnRender is called once for each row",
|
||||
"Single column - fnRender is called twice for each row",
|
||||
null,
|
||||
function () { return mTmp == 57; }
|
||||
function () { return mTmp == 114; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
@ -51,33 +51,6 @@ $(document).ready( function () {
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is row number",
|
||||
function () {
|
||||
var iCount = 0;
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( iCount != a.iDataRow )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
iCount++;
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is the column",
|
||||
function () {
|
||||
|
@ -21,9 +21,9 @@ $(document).ready( function () {
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Single column - fnRender is called once for each row",
|
||||
"Single column - fnRender is called twice for each row",
|
||||
null,
|
||||
function () { return mTmp == 10; }
|
||||
function () { return mTmp == 20; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
@ -53,34 +53,6 @@ $(document).ready( function () {
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is row number",
|
||||
function () {
|
||||
var iCount = 0;
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"bServerSide": true,
|
||||
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( iCount != a.iDataRow )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
iCount++;
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is the column",
|
||||
function () {
|
||||
|
@ -23,9 +23,9 @@ $(document).ready( function () {
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Single column - fnRender is called once for each row",
|
||||
"Single column - fnRender is called twice for each row",
|
||||
null,
|
||||
function () { return mTmp == 57; }
|
||||
function () { return mTmp == 114; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
@ -57,36 +57,6 @@ $(document).ready( function () {
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is row number",
|
||||
function () {
|
||||
var iCount = 0;
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
|
||||
"aoColumns": [
|
||||
{ "mDataSource": "engine" },
|
||||
{
|
||||
"mDataSource": "browser",
|
||||
"fnRender": function (a) {
|
||||
if ( iCount != a.iDataRow )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
iCount++;
|
||||
return a.aData['browser'];
|
||||
}
|
||||
},
|
||||
{ "mDataSource": "platform" },
|
||||
{ "mDataSource": "version" },
|
||||
{ "mDataSource": "grade" }
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is the column",
|
||||
function () {
|
||||
|
@ -0,0 +1,403 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "Sanity checks for DataTables with delayed DOM creation" );
|
||||
|
||||
$(document).ready( function () {
|
||||
var oInit = {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
};
|
||||
$('#example').dataTable( oInit );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"10 rows shown on the first page",
|
||||
null,
|
||||
function () { return $('#example tbody tr').length == 10; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"10 TR elements available from fnGetNodes",
|
||||
null,
|
||||
function () { return $('#example').dataTable().fnGetNodes().length == 10; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Initial sort occured",
|
||||
null,
|
||||
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (first click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"14 TR elements available from fnGetNodes after sort",
|
||||
null,
|
||||
function () { return $('#example').dataTable().fnGetNodes().length == 14; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (second click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (third click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (first click) on numeric column",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "-"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (second click) on numeric column",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting multi-column (first click)",
|
||||
function () {
|
||||
$('#example thead th:eq(0)').click();
|
||||
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
|
||||
function () { var b =
|
||||
$('#example tbody td:eq(0)').html() == "Gecko" &&
|
||||
$('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting multi-column - sorting second column only",
|
||||
function () {
|
||||
$('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
/* Basic paging */
|
||||
oTest.fnTest(
|
||||
"Paging to second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Paging to first page",
|
||||
function () { $('#example_previous').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Attempting to page back beyond the first page",
|
||||
function () { $('#example_previous').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
/* Changing length */
|
||||
oTest.fnTest(
|
||||
"Changing table length to 25 records",
|
||||
function () { $("select[name=example_length]").val('25').change(); },
|
||||
function () { return $('#example tbody tr').length == 25; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 50 records",
|
||||
function () { $("select[name=example_length]").val('50').change(); },
|
||||
function () { return $('#example tbody tr').length == 50; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 100 records",
|
||||
function () { $("select[name=example_length]").val('100').change(); },
|
||||
function () { return $('#example tbody tr').length == 57; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 10 records",
|
||||
function () { $("select[name=example_length]").val('10').change(); },
|
||||
function () { return $('#example tbody tr').length == 10; }
|
||||
);
|
||||
|
||||
/*
|
||||
* Information element
|
||||
*/
|
||||
oTest.fnTest(
|
||||
"Information on zero config",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information on second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information on third page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information on last page",
|
||||
function () {
|
||||
$('#example_next').click();
|
||||
$('#example_next').click();
|
||||
$('#example_next').click();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information back on first page",
|
||||
function () {
|
||||
$('#example_previous').click();
|
||||
$('#example_previous').click();
|
||||
$('#example_previous').click();
|
||||
$('#example_previous').click();
|
||||
$('#example_previous').click();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with 25 records",
|
||||
function () { $("select[name=example_length]").val('25').change(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with 25 records - second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with 100 records - first page",
|
||||
function () {
|
||||
$('#example_previous').click();
|
||||
$("select[name=example_length]").val('100').change();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information back to 10 records",
|
||||
function () {
|
||||
$('#example_previous').click();
|
||||
$("select[name=example_length]").val('10').change();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter 'Win'",
|
||||
function () { $('#example_filter input').val("Win").keyup(); },
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter 'Win' second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter 'Win' last page",
|
||||
function () {
|
||||
$('#example_next').click();
|
||||
$('#example_next').click();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter 'Win' back to first page",
|
||||
function () {
|
||||
$('#example_previous').click();
|
||||
$('#example_previous').click();
|
||||
$('#example_previous').click();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter 'Win' second page - second time",
|
||||
function () {
|
||||
$('#example_next').click();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter increased to 'Win 98'",
|
||||
function () { $('#example_filter input').val("Win 98").keyup(); },
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter decreased to 'Win'",
|
||||
function () { $('#example_filter input').val("Win").keyup(); },
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter 'Win' second page - third time",
|
||||
function () {
|
||||
$('#example_next').click();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information with filter removed",
|
||||
function () { $('#example_filter input').val("").keyup(); },
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Filtering
|
||||
*/
|
||||
oTest.fnWaitTest(
|
||||
"Filter 'W' - rows",
|
||||
function () {
|
||||
/* Reset the table such that the old sorting doesn't mess things up */
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( oInit );
|
||||
$('#example_filter input').val("W").keyup(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'W' - info",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Wi'",
|
||||
function () { $('#example_filter input').val("Wi").keyup(); },
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win'",
|
||||
function () { $('#example_filter input').val("Win").keyup(); },
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win' - sorting column 1",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win' - sorting column 1 info",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win' - sorting column 1 reverse",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win XP' - maintaing reverse sorting col 1",
|
||||
function () { $('#example_filter input').val("Win XP").keyup(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win XP' - sorting col 3",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win XP' - sorting col 3 - reversed",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'Win' - sorting col 3 - reversed info",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'nothinghere'",
|
||||
function () { $('#example_filter input').val("nothinghere").keyup(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() ==
|
||||
"No matching records found"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter 'nothinghere' - info",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Filter back to blank and 1st column sorting",
|
||||
function () {
|
||||
$('#example_filter input').val("").keyup();
|
||||
$('#example thead th:eq(0)').click();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Prefixing a filter entry",
|
||||
function () {
|
||||
$('#example_filter input').val("Win").keyup();
|
||||
$('#example_filter input').val("GeckoWin").keyup();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Prefixing a filter entry with space",
|
||||
function () {
|
||||
$('#example_filter input').val("Gecko Win").keyup();
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
212
media/unit_testing/tests_onhold/6_delayed_rendering/aaSorting.js
Normal file
212
media/unit_testing/tests_onhold/6_delayed_rendering/aaSorting.js
Normal file
@ -0,0 +1,212 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aaSorting" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default sorting is single column",
|
||||
null,
|
||||
function () {
|
||||
return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object';
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default sorting is first column asc",
|
||||
null,
|
||||
function () {
|
||||
return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 &&
|
||||
oSettings.aaSorting[0][1] == 'asc';
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting is applied",
|
||||
null,
|
||||
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Custom sorting on single string column asc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['1','asc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Custom sorting on single string column desc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['1','desc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Custom sorting on single int column asc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['1','asc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(3)').html() == "-"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Custom sorting on single int column desc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['1','desc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string asc / string asc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','asc'], ['1','asc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string asc / string desc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','asc'], ['1','desc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string desc / string asc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','desc'], ['1','asc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string desc / string desc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','desc'], ['1','desc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string asc / int asc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','asc'], ['3','asc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(3)').html() == "1"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string asc / int desc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','asc'], ['3','desc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(3)').html() == "1.9"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string desc / int asc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','desc'], ['3','asc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(3)').html() == "125.5"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (2 column) - string desc / int desc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','desc'], ['3','desc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column sorting (3 column) - string asc / int asc / string asc",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSorting": [['0','asc'], ['3','asc'], ['1','asc']]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,70 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aaSortingFixed" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"No fixed sorting by default",
|
||||
null,
|
||||
function () {
|
||||
return oSettings.aaSortingFixed == null;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Fixed sorting on first column (string/asc) with user sorting on second column (string/asc)",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSortingFixed": [['0','asc']],
|
||||
"fnInitComplete": function () {
|
||||
$('#example thead th:eq(1)').click();
|
||||
}
|
||||
} );
|
||||
//
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Fixed sorting on first column (string/asc) with user sorting on second column (string/desc)",
|
||||
function () {
|
||||
$('#example thead th:eq(1)').click();
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/asc)",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aaSortingFixed": [['3','asc']]
|
||||
} );
|
||||
$('#example thead th:eq(1)').click();
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/desc)",
|
||||
function () {
|
||||
$('#example thead th:eq(1)').click();
|
||||
},
|
||||
function () { return $('#example tbody td:eq(1)').html() == "PSP browser"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
79
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bSearchable.js
Executable file
79
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bSearchable.js
Executable file
@ -0,0 +1,79 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.bSeachable" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Columns are searchable by default",
|
||||
function () { oTable.fnFilter("Camino"); },
|
||||
function () {
|
||||
if ( $('#example tbody tr:eq(0) td:eq(1)')[0] )
|
||||
return $('#example tbody tr:eq(0) td:eq(1)').html().match(/Camino/);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Disabling sorting on a column removes it from the global filter",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "bSearchable": false },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
oTable.fnFilter("Camino");
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Disabled on one column has no effect on other columns",
|
||||
function () { oTable.fnFilter("Webkit"); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Webkit"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Disable filtering on multiple columns",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
{ "bSearchable": false },
|
||||
{ "bSearchable": false },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
oTable.fnFilter("Webkit");
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Filter on second disabled column",
|
||||
function () { oTable.fnFilter("Camino"); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
112
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bSortable.js
Executable file
112
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bSortable.js
Executable file
@ -0,0 +1,112 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.bSortable" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"All columns are sortable by default",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Can disable sorting from one column",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "bSortable": false },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
$('#example thead th:eq(1)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Disabled column has no sorting class",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Other columns can still sort",
|
||||
function () {
|
||||
$('#example thead th:eq(4)').click();
|
||||
$('#example thead th:eq(4)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Disable sorting on multiple columns - no sorting classes",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "bSortable": false },
|
||||
null,
|
||||
{ "bSortable": false },
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var bReturn =
|
||||
$('#example thead th:eq(1)').hasClass("sorting") ||
|
||||
$('#example thead th:eq(3)').hasClass("sorting")
|
||||
return bReturn == false;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting on disabled column 1 has no effect",
|
||||
function () {
|
||||
$('#example thead th:eq(1)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting on disabled column 2 has no effect",
|
||||
function () {
|
||||
$('#example thead th:eq(3)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Second sort on disabled column 2 has no effect",
|
||||
function () {
|
||||
$('#example thead th:eq(3)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Even with multiple disabled sorting columns other columns can still sort",
|
||||
function () {
|
||||
$('#example thead th:eq(4)').click();
|
||||
$('#example thead th:eq(4)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
151
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bUseRendered.js
Executable file
151
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bUseRendered.js
Executable file
@ -0,0 +1,151 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.bUseRendered" );
|
||||
|
||||
/* bUseRendered is used to alter sorting data, if false then the original data is used for
|
||||
* sorting rather than the rendered data
|
||||
*/
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var mTmp = 0;
|
||||
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( a.iDataRow == 0 ) {
|
||||
mTmp++;
|
||||
return "aaa";
|
||||
} else
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default for bUseRendered is true - rendered data is used for sorting",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"When bUseRendered is false, original data is used for sorting",
|
||||
function () {
|
||||
mTmp = 0;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{
|
||||
"bUseRendered": false,
|
||||
"fnRender": function (a) {
|
||||
if ( a.iDataRow == 0 ) {
|
||||
mTmp++;
|
||||
return "aaa";
|
||||
} else {
|
||||
return a.aData[a.iDataColumn];
|
||||
}
|
||||
}
|
||||
},
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
$('#example thead th:eq(1)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"bUseRendered set to false on one columns and true (default) on two others",
|
||||
function () {
|
||||
mTmp = 0;
|
||||
var mTmp2 = 0;
|
||||
var mTmp3 = 0;
|
||||
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
{
|
||||
"fnRender": function (a) {
|
||||
if ( a.iDataRow == 0 ) {
|
||||
mTmp++;
|
||||
return "aaa1";
|
||||
} else {
|
||||
return a.aData[a.iDataColumn];
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"bUseRendered": false,
|
||||
"fnRender": function (a) {
|
||||
if ( a.iDataRow == 0 ) {
|
||||
mTmp2++;
|
||||
return "aaa2";
|
||||
} else {
|
||||
return a.aData[a.iDataColumn];
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"fnRender": function (a) {
|
||||
if ( a.iDataRow == 0 ) {
|
||||
mTmp3++;
|
||||
return "zzz3";
|
||||
} else {
|
||||
return a.aData[a.iDataColumn];
|
||||
}
|
||||
}
|
||||
},
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column rendering - 2nd column sorting",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column rendering - 3rd column sorting",
|
||||
function () {
|
||||
$('#example thead th:eq(2)').click();
|
||||
$('#example thead th:eq(2)').click();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column rendering - 4th column sorting",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multi-column rendering - 5th column sorting",
|
||||
function () { $('#example thead th:eq(4)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
127
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bVisible.js
Executable file
127
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bVisible.js
Executable file
@ -0,0 +1,127 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.bVisible" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"All columns are visible by default",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(0) td').length == 5; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Can hide one column and it removes td column from DOM",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "bVisible": false },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td').length == 4; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Can hide one column and it removes thead th column from DOM",
|
||||
null,
|
||||
function () { return $('#example thead tr:eq(0) th').length == 4; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"The correct thead column has been hidden",
|
||||
null,
|
||||
function () {
|
||||
var jqNodes = $('#example thead tr:eq(0) th');
|
||||
var bReturn =
|
||||
jqNodes[0].innerHTML == "Rendering engine" &&
|
||||
jqNodes[1].innerHTML == "Platform(s)" &&
|
||||
jqNodes[2].innerHTML == "Engine version" &&
|
||||
jqNodes[3].innerHTML == "CSS grade";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"The correct tbody column has been hidden",
|
||||
function () {
|
||||
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } );
|
||||
},
|
||||
function () {
|
||||
var jqNodes = $('#example tbody tr:eq(0) td');
|
||||
var bReturn =
|
||||
jqNodes[0].innerHTML == "Gecko" &&
|
||||
jqNodes[1].innerHTML == "Gnome" &&
|
||||
jqNodes[2].innerHTML == "1.8" &&
|
||||
jqNodes[3].innerHTML == "A";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Can hide multiple columns and it removes td column from DOM",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "bVisible": false },
|
||||
{ "bVisible": false },
|
||||
null,
|
||||
{ "bVisible": false }
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td').length == 2; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multiple hide - removes thead th column from DOM",
|
||||
null,
|
||||
function () { return $('#example thead tr:eq(0) th').length == 2; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multiple hide - the correct thead columns have been hidden",
|
||||
null,
|
||||
function () {
|
||||
var jqNodes = $('#example thead tr:eq(0) th');
|
||||
var bReturn =
|
||||
jqNodes[0].innerHTML == "Rendering engine" &&
|
||||
jqNodes[1].innerHTML == "Engine version"
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Multiple hide - the correct tbody columns have been hidden",
|
||||
function () {
|
||||
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } );
|
||||
},
|
||||
function () {
|
||||
var jqNodes = $('#example tbody tr:eq(0) td');
|
||||
var bReturn =
|
||||
jqNodes[0].innerHTML == "Gecko" &&
|
||||
jqNodes[1].innerHTML == "1"
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
189
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.fnRender.js
Executable file
189
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.fnRender.js
Executable file
@ -0,0 +1,189 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.fnRender" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var mTmp = 0;
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
mTmp++;
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Single column - fnRender is called once for each row, plus once for the node draw",
|
||||
null,
|
||||
function () { return mTmp == 67; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Confirm that fnRender passes one argument (an object) with three parameters",
|
||||
function () {
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( arguments.length != 1 || typeof a.iDataRow=='undefined' ||
|
||||
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is row number",
|
||||
function () {
|
||||
var iCount = 0;
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( iCount != a.iDataRow )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
iCount++;
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender iDataColumn is the column",
|
||||
function () {
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( a.iDataColumn != 1 )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRender aData is data array of correct size",
|
||||
function () {
|
||||
mTmp = true;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
if ( a.aData.length != 5 )
|
||||
{
|
||||
mTmp = false;
|
||||
}
|
||||
return a.aData[a.iDataColumn];
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return mTmp; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Passed back data is put into the DOM",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
return 'unittest';
|
||||
} },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Passed back data is put into the DOM",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
null,
|
||||
{ "fnRender": function (a) {
|
||||
return 'unittest1';
|
||||
} },
|
||||
{ "fnRender": function (a) {
|
||||
return 'unittest2';
|
||||
} },
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var bReturn =
|
||||
$('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' &&
|
||||
$('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2';
|
||||
return bReturn; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
92
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.iDataSort.js
Executable file
92
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.iDataSort.js
Executable file
@ -0,0 +1,92 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.iDataSort" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Should know that sorting already works by default from other tests, so we can jump
|
||||
* right in here
|
||||
*/
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "iDataSort": 4 },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting on first column is uneffected",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting on second column is the order of the fifth",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Reserve sorting on second column uses fifth column as well",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting on 5th column retains it's own sorting",
|
||||
function () { $('#example thead th:eq(4)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Use 2nd col for sorting 5th col and via-versa - no effect on first col sorting",
|
||||
function () {
|
||||
mTmp = 0;
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "iDataSort": 4 },
|
||||
null,
|
||||
null,
|
||||
{ "iDataSort": 1 }
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"2nd col sorting uses fifth col",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"2nd col sorting uses fifth col - reversed",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"5th col sorting uses 2nd col",
|
||||
function () { $('#example thead th:eq(4)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"5th col sorting uses 2nd col - reversed",
|
||||
function () { $('#example thead th:eq(4)').click(); },
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1'; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
118
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sClass.js
Executable file
118
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sClass.js
Executable file
@ -0,0 +1,118 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.sClass" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"By default the test class hasn't been applied to the column (sanity!)",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest') == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - first row",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
null,
|
||||
{ "sClass": 'unittest' },
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(1) td:eq(2)').hasClass('unittest'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - third row",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(3) td:eq(2)').hasClass('unittest'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - last row",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(9) td:eq(2)').hasClass('unittest'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - has not applied to other columns - 1st",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest') == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - has not applied to other columns - 5th",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(3) td:eq(4)').hasClass('unittest') == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - seventh row - second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return $('#example tbody tr:eq(6) td:eq(2)').hasClass('unittest'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - has not applied to header",
|
||||
null,
|
||||
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Add a class to a single column - has not applied to footer",
|
||||
null,
|
||||
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Class defined for multiple columns - first row",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
{ "sClass": 'unittest2' },
|
||||
null,
|
||||
null,
|
||||
{ "sClass": 'unittest1' },
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var bReturn =
|
||||
$('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest2') &&
|
||||
$('#example tbody tr:eq(8) td:eq(3)').hasClass('unittest1');
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Class defined for multiple columns - has not applied to other columns - 5th 1",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(4)').hasClass('unittest1') == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Class defined for multiple columns - has not applied to other columns - 5th 2",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(6) td:eq(4)').hasClass('unittest2') == false; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
29
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sName.js
Executable file
29
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sName.js
Executable file
@ -0,0 +1,29 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.sName" );
|
||||
|
||||
/* This has no effect at all in DOM methods - so we just check that it has applied the name */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
{ "sName": 'unit test' },
|
||||
null
|
||||
]
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Names are stored in the columns object",
|
||||
null,
|
||||
function () { return oSettings.aoColumns[3].sName =="unit test"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
85
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sTitle.js
Executable file
85
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sTitle.js
Executable file
@ -0,0 +1,85 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.sTitle" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"If not given, then the columns titles are empty",
|
||||
null,
|
||||
function () {
|
||||
var jqNodes = $('#example thead tr:eq(0) th');
|
||||
var bReturn =
|
||||
jqNodes[0].innerHTML == "Rendering engine" &&
|
||||
jqNodes[1].innerHTML == "Browser" &&
|
||||
jqNodes[2].innerHTML == "Platform(s)" &&
|
||||
jqNodes[3].innerHTML == "Engine version" &&
|
||||
jqNodes[4].innerHTML == "CSS grade";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Can set a single column title - and others are read from DOM",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "sTitle": 'unit test' },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var jqNodes = $('#example thead tr:eq(0) th');
|
||||
var bReturn =
|
||||
jqNodes[0].innerHTML == "Rendering engine" &&
|
||||
jqNodes[1].innerHTML == "unit test" &&
|
||||
jqNodes[2].innerHTML == "Platform(s)" &&
|
||||
jqNodes[3].innerHTML == "Engine version" &&
|
||||
jqNodes[4].innerHTML == "CSS grade";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Can set multiple column titles",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "sTitle": 'unit test 1' },
|
||||
null,
|
||||
null,
|
||||
{ "sTitle": 'unit test 2' }
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var jqNodes = $('#example thead tr:eq(0) th');
|
||||
var bReturn =
|
||||
jqNodes[0].innerHTML == "Rendering engine" &&
|
||||
jqNodes[1].innerHTML == "unit test 1" &&
|
||||
jqNodes[2].innerHTML == "Platform(s)" &&
|
||||
jqNodes[3].innerHTML == "Engine version" &&
|
||||
jqNodes[4].innerHTML == "unit test 2";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
90
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sWidth.js
Executable file
90
media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sWidth.js
Executable file
@ -0,0 +1,90 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoColumns.sWidth" );
|
||||
|
||||
/* NOTE - we need to disable the auto width for the majority of these test in order to preform
|
||||
* these tests as the auto width will convert the width to a px value. We can do 'non-exact' tests
|
||||
* with auto width enabled however to ensure it scales columns as required
|
||||
*/
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bAutoWidth": false,
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "sWidth": '40%' },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"With auto width disabled the width for one column is appled",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"With auto width disabled the width for one column is appled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bAutoWidth": false,
|
||||
"aoColumns": [
|
||||
null,
|
||||
null,
|
||||
{ "sWidth": '20%' },
|
||||
{ "sWidth": '30%' },
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var bReturn =
|
||||
$('#example thead th:eq(2)')[0].style.width == "20%" &&
|
||||
$('#example thead th:eq(3)')[0].style.width == "30%";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"With auto width, it will make the smallest column the largest with percentage width given",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoColumns": [
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
{ "sWidth": '40%' },
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var anThs = $('#example thead th');
|
||||
var a0 = anThs[0].offsetWidth;
|
||||
var a1 = anThs[1].offsetWidth;
|
||||
var a2 = anThs[2].offsetWidth;
|
||||
var a3 = anThs[3].offsetWidth;
|
||||
var a4 = anThs[4].offsetWidth;
|
||||
|
||||
if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,125 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "aoSearchCols" );
|
||||
|
||||
/* We could be here forever testing this one, so we test a limited subset on a couple of colums */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default should be to have a empty colums array",
|
||||
null,
|
||||
function () {
|
||||
var bReturn =
|
||||
oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex &&
|
||||
oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex &&
|
||||
oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex &&
|
||||
oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex &&
|
||||
oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search on a single column - no regex statement given",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoSearchCols": [
|
||||
null,
|
||||
{ "sSearch": "Mozilla" },
|
||||
null,
|
||||
{ "sSearch": "1" },
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search on two columns - no regex statement given",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoSearchCols": [
|
||||
null,
|
||||
{ "sSearch": "Mozilla" },
|
||||
null,
|
||||
{ "sSearch": "1.5" },
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search on single column - escape regex false",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoSearchCols": [
|
||||
{ "sSearch": ".*ML", "bEscapeRegex": false },
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search on two columns - escape regex false on first, true on second",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoSearchCols": [
|
||||
{ "sSearch": ".*ML", "bEscapeRegex": false },
|
||||
{ "sSearch": "3.3", "bEscapeRegex": true },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search on two columns (no records) - escape regex false on first, true on second",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"aoSearchCols": [
|
||||
{ "sSearch": ".*ML", "bEscapeRegex": false },
|
||||
{ "sSearch": "Allan", "bEscapeRegex": true },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
|
||||
);
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,109 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "asStripClasses" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default row striping is applied",
|
||||
null,
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0)').hasClass('odd') &&
|
||||
$('#example tbody tr:eq(1)').hasClass('even') &&
|
||||
$('#example tbody tr:eq(2)').hasClass('odd') &&
|
||||
$('#example tbody tr:eq(3)').hasClass('even');
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Row striping on the second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0)').hasClass('odd') &&
|
||||
$('#example tbody tr:eq(1)').hasClass('even') &&
|
||||
$('#example tbody tr:eq(2)').hasClass('odd') &&
|
||||
$('#example tbody tr:eq(3)').hasClass('even');
|
||||
}
|
||||
);
|
||||
|
||||
/* No striping */
|
||||
oTest.fnWaitTest(
|
||||
"No row striping",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"asStripClasses": []
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
if ( typeof $('#example tbody tr:eq(1)')[0] == 'undefined' )
|
||||
{
|
||||
/* Use the 'wait for' to allow this to become true */
|
||||
return false;
|
||||
}
|
||||
return $('#example tbody tr:eq(0)')[0].className == "" &&
|
||||
$('#example tbody tr:eq(1)')[0].className == "" &&
|
||||
$('#example tbody tr:eq(2)')[0].className == "" &&
|
||||
$('#example tbody tr:eq(3)')[0].className == "";
|
||||
}
|
||||
);
|
||||
|
||||
/* Custom striping */
|
||||
oTest.fnWaitTest(
|
||||
"Custom striping [2]",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"asStripClasses": [ 'test1', 'test2' ]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0)').hasClass('test1') &&
|
||||
$('#example tbody tr:eq(1)').hasClass('test2') &&
|
||||
$('#example tbody tr:eq(2)').hasClass('test1') &&
|
||||
$('#example tbody tr:eq(3)').hasClass('test2');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/* long array of striping */
|
||||
oTest.fnWaitTest(
|
||||
"Custom striping [4]",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"asStripClasses": [ 'test1', 'test2', 'test3', 'test4' ]
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0)').hasClass('test1') &&
|
||||
$('#example tbody tr:eq(1)').hasClass('test2') &&
|
||||
$('#example tbody tr:eq(2)').hasClass('test3') &&
|
||||
$('#example tbody tr:eq(3)').hasClass('test4');
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Custom striping is restarted on second page [2]",
|
||||
function () { $('#example_next').click(); },
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0)').hasClass('test1') &&
|
||||
$('#example tbody tr:eq(1)').hasClass('test2') &&
|
||||
$('#example tbody tr:eq(2)').hasClass('test3') &&
|
||||
$('#example tbody tr:eq(3)').hasClass('test4');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,145 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bAutoWidth" );
|
||||
|
||||
/* It's actually a little tricky to test this. We can't test absolute numbers because
|
||||
* different browsers and different platforms will render the width of the columns slightly
|
||||
* differently. However, we certainly can test the principle of what should happen (column
|
||||
* width doesn't change over pages)
|
||||
*/
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Auto width is enabled by default",
|
||||
null,
|
||||
function () { return oSettings.oFeatures.bAutoWidth; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"First column has a width assigned to it",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(0)').attr('style').match(/width/i); }
|
||||
);
|
||||
|
||||
/*
|
||||
This would seem like a better test - but there appear to be difficulties with tables
|
||||
which are bigger (calculated) than there is actually room for. I suspect this is actually
|
||||
a bug in datatables
|
||||
oTest.fnWaitTest(
|
||||
"Check column widths on first page match second page",
|
||||
null,
|
||||
function () {
|
||||
var anThs = $('#example thead th');
|
||||
var a0 = anThs[0].offsetWidth;
|
||||
var a1 = anThs[1].offsetWidth;
|
||||
var a2 = anThs[2].offsetWidth;
|
||||
var a3 = anThs[3].offsetWidth;
|
||||
var a4 = anThs[4].offsetWidth;
|
||||
$('#example_next').click();
|
||||
var b0 = anThs[0].offsetWidth;
|
||||
var b1 = anThs[1].offsetWidth;
|
||||
var b2 = anThs[2].offsetWidth;
|
||||
var b3 = anThs[3].offsetWidth;
|
||||
var b4 = anThs[4].offsetWidth;
|
||||
console.log( a0, b0, a1, b1, a2, b2, a3, b3 );
|
||||
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check column widths on second page match thid page",
|
||||
null,
|
||||
function () {
|
||||
var anThs = $('#example thead th');
|
||||
var a0 = anThs[0].offsetWidth;
|
||||
var a1 = anThs[1].offsetWidth;
|
||||
var a2 = anThs[2].offsetWidth;
|
||||
var a3 = anThs[3].offsetWidth;
|
||||
var a4 = anThs[4].offsetWidth;
|
||||
$('#example_next').click();
|
||||
var b0 = anThs[0].offsetWidth;
|
||||
var b1 = anThs[1].offsetWidth;
|
||||
var b2 = anThs[2].offsetWidth;
|
||||
var b3 = anThs[3].offsetWidth;
|
||||
var b4 = anThs[4].offsetWidth;
|
||||
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
);
|
||||
*/
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Auto width can be disabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bAutoWidth": false
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oFeatures.bAutoWidth == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"First column does not have a width assigned to it",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(0)').attr('style') == null; }
|
||||
);
|
||||
|
||||
/*
|
||||
oTest.fnWaitTest(
|
||||
"Check column widths on first page do not match second page",
|
||||
null,
|
||||
function () {
|
||||
var anThs = $('#example thead th');
|
||||
var a0 = anThs[0].offsetWidth;
|
||||
var a1 = anThs[1].offsetWidth;
|
||||
var a2 = anThs[2].offsetWidth;
|
||||
var a3 = anThs[3].offsetWidth;
|
||||
var a4 = anThs[4].offsetWidth;
|
||||
$('#example_next').click();
|
||||
var b0 = anThs[0].offsetWidth;
|
||||
var b1 = anThs[1].offsetWidth;
|
||||
var b2 = anThs[2].offsetWidth;
|
||||
var b3 = anThs[3].offsetWidth;
|
||||
var b4 = anThs[4].offsetWidth;
|
||||
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
);
|
||||
*/
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Auto width enabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bAutoWidth": true
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oFeatures.bAutoWidth; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,47 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bFilter" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Filtering div exists by default",
|
||||
null,
|
||||
function () { return document.getElementById('example_filter') != null; }
|
||||
);
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Fltering can be disabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bFilter": false
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_filter') == null; }
|
||||
);
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Filtering enabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bFilter": true
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_filter') != null; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
47
media/unit_testing/tests_onhold/6_delayed_rendering/bInfo.js
Normal file
47
media/unit_testing/tests_onhold/6_delayed_rendering/bInfo.js
Normal file
@ -0,0 +1,47 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bInfo" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info div exists by default",
|
||||
null,
|
||||
function () { return document.getElementById('example_info') != null; }
|
||||
);
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Info can be disabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bInfo": false
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info') == null; }
|
||||
);
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Info enabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bInfo": true
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info') != null; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,78 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bLengthChange" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Length div exists by default",
|
||||
null,
|
||||
function () { return document.getElementById('example_length') != null; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Four default options",
|
||||
null,
|
||||
function () { return $("select[name=example_length] option").length == 4; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default options",
|
||||
null,
|
||||
function () {
|
||||
var opts = $("select[name='example_length'] option");
|
||||
return opts[0].getAttribute('value') == 10 && opts[1].getAttribute('value') == 25 &&
|
||||
opts[2].getAttribute('value') == 50 && opts[3].getAttribute('value') == 100;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info takes length into account",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Change length can be disabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bLengthChange": false
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_length') == null; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Information takes length disabled into account",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Length change enabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bLengthChange": true
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_length') != null; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,62 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bPaginate" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Pagiantion div exists by default",
|
||||
null,
|
||||
function () { return document.getElementById('example_paginate') != null; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Information div takes paging into account",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Pagiantion can be disabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bPaginate": false
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_paginate') == null; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Information div takes paging disabled into account",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML ==
|
||||
"Showing 1 to 57 of 57 entries"; }
|
||||
);
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Pagiantion enabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bPaginate": true
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_paginate') != null; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,106 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bProcessing" );
|
||||
|
||||
/* It's actually a bit hard to set this one due to the fact that it will only be shown
|
||||
* when DataTables is doing some kind of processing. The server-side processing is a bit
|
||||
* better to test this than here - so we just the interal functions to enable it and check
|
||||
* that it is available
|
||||
*/
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing is off by default",
|
||||
null,
|
||||
function () { return oSettings.oFeatures.bProcessing == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div is not in the DOM",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); },
|
||||
function () { return document.getElementById('example_processing') == null; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div cannot be shown",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); },
|
||||
function () { return document.getElementById('example_processing') == null; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div cannot be hidden",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); },
|
||||
function () { return document.getElementById('example_processing') == null; }
|
||||
);
|
||||
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Processing can be enabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bProcessing": true
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oFeatures.bProcessing == true; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div is in the DOM",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); },
|
||||
function () { return document.getElementById('example_processing'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div is hidden by default",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); },
|
||||
function () { return document.getElementById('example_processing').style.visibility = "hidden"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div can be shown",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); },
|
||||
function () { return document.getElementById('example_processing').style.visibility = "visible"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div can be hidden",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); },
|
||||
function () { return document.getElementById('example_processing').style.visibility = "hidden"; }
|
||||
);
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Processing disabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bProcessing": false
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oFeatures.bProcessing == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing div is not in the DOM",
|
||||
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); },
|
||||
function () { return document.getElementById('example_processing') == null; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,21 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bServerSide" );
|
||||
|
||||
/* Not interested in server-side processing here other than to check that it is off */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Server side is off by default",
|
||||
null,
|
||||
function () { return oSettings.oFeatures.bServerSide == false; }
|
||||
);
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
102
media/unit_testing/tests_onhold/6_delayed_rendering/bSort.js
Normal file
102
media/unit_testing/tests_onhold/6_delayed_rendering/bSort.js
Normal file
@ -0,0 +1,102 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bSort" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting is on by default",
|
||||
null,
|
||||
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting Asc by default class applied",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Click on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting class removed from first column",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting asc class applied to second column",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Reverse on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting acs class removed from second column",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting desc class applied to second column",
|
||||
null,
|
||||
function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); }
|
||||
);
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Pagiantion can be disabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bSort": false
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(3)').html() == "4"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Click on second column has no effect",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "4"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Reverse on second column has no effect",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "4"; }
|
||||
);
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Sorting enabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bSort": true
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,135 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "bSortClasses" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting classes are applied by default",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting classes are applied to all required cells",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(7) td:eq(0)').hasClass('sorting_1'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting classes are not applied to non-sorting columns",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_1') == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting multi-column - add column 1",
|
||||
function () {
|
||||
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') &&
|
||||
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2');
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting multi-column - add column 2",
|
||||
function () {
|
||||
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); },
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') &&
|
||||
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') &&
|
||||
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3');
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting multi-column - add column 3",
|
||||
function () {
|
||||
oDispacher.click( $('#example thead th:eq(3)')[0], { 'shift': true } );
|
||||
},
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') &&
|
||||
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') &&
|
||||
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') &&
|
||||
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3');
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Remove sorting classes on single column sort",
|
||||
function () {
|
||||
$('#example thead th:eq(4)').click();
|
||||
},
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false &&
|
||||
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false &&
|
||||
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false &&
|
||||
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3') == false;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting class 1 was added",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(1) td:eq(4)').hasClass('sorting_1'); }
|
||||
);
|
||||
|
||||
|
||||
/* Check can disable */
|
||||
oTest.fnWaitTest(
|
||||
"Sorting classes can be disabled",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bSortClasses": false
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting classes disabled - add column 1 - no effect",
|
||||
function () {
|
||||
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false &&
|
||||
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Sorting classes disabled - add column 2 - no effect",
|
||||
function () {
|
||||
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); },
|
||||
function () {
|
||||
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false &&
|
||||
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false &&
|
||||
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/* Enable makes no difference */
|
||||
oTest.fnWaitTest(
|
||||
"Sorting classes enabled override",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bSortClasses": true
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,102 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "fnDrawCallback" );
|
||||
|
||||
/* Fairly boring function compared to the others! */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
var mPass, bInit;
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default should be null",
|
||||
null,
|
||||
function () { return oSettings.fnDrawCallback == null; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"One argument passed",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = -1;
|
||||
bInit = false;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnDrawCallback": function ( ) {
|
||||
mPass = arguments.length;
|
||||
},
|
||||
"fnInitComplete": function () {
|
||||
bInit = true;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 1 && bInit; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"That one argument is the settings object",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
bInit = false;
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnDrawCallback": function ( oSettings ) {
|
||||
mPass = oSettings;
|
||||
},
|
||||
"fnInitComplete": function () {
|
||||
bInit = true;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return oTable.fnSettings() == mPass && bInit; }
|
||||
);
|
||||
|
||||
|
||||
/* The draw callback is called once for the init and then when the data is added */
|
||||
oTest.fnWaitTest(
|
||||
"fnRowCallback called once on first draw",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = 0;
|
||||
bInit = false;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnDrawCallback": function ( ) {
|
||||
mPass++;
|
||||
},
|
||||
"fnInitComplete": function () {
|
||||
bInit = true;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 2 && bInit; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRowCallback called once on each draw there after as well",
|
||||
function () {
|
||||
$('#example_next').click();
|
||||
$('#example_next').click();
|
||||
$('#example_next').click();
|
||||
},
|
||||
function () { return mPass == 5; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,200 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "fnHeaderCallback" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
var mPass, bInit;
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default should be null",
|
||||
null,
|
||||
function () { return oSettings.fnHeaderCallback == null; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Five arguments passed",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = -1;
|
||||
bInit = false;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( ) {
|
||||
mPass = arguments.length;
|
||||
},
|
||||
"fnInitComplete": function () {
|
||||
bInit = true;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 5 && bInit; }
|
||||
);
|
||||
|
||||
|
||||
/* The header callback is called once for the init and then when the data is added */
|
||||
oTest.fnWaitTest(
|
||||
"fnHeaderCallback called once per draw",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = 0;
|
||||
bInit = false;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
|
||||
mPass++;
|
||||
},
|
||||
"fnInitComplete": function () {
|
||||
bInit = true;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 2 && bInit; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRowCallback called on paging (i.e. another draw)",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return mPass == 3; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRowCallback allows us to alter row information",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
|
||||
nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records";
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"iStart correct on first page",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = true;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
|
||||
if ( iStart != 0 )
|
||||
{
|
||||
mPass = false;
|
||||
}
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"iStart correct on second page",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = false;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
|
||||
if ( iStart == 10 )
|
||||
{
|
||||
mPass = true;
|
||||
}
|
||||
},
|
||||
"fnInitComplete": function () {
|
||||
$('#example_next').click();
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"iEnd correct on second page",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = false;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
|
||||
if ( iEnd == 20 )
|
||||
{
|
||||
mPass = true;
|
||||
}
|
||||
},
|
||||
"fnInitComplete": function () {
|
||||
$('#example_next').click();
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"aiDisplay length is full data when not filtered",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = false;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
|
||||
if ( aiDisplay.length == 57 )
|
||||
{
|
||||
mPass = true;
|
||||
}
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"aiDisplay length is 9 when filtering on 'Mozilla'",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = false;
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
|
||||
if ( aiDisplay.length == 9 )
|
||||
{
|
||||
mPass = true;
|
||||
}
|
||||
}
|
||||
} );
|
||||
oTable.fnFilter( "Mozilla" );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,105 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "fnInitComplete" );
|
||||
|
||||
/* Fairly boring function compared to the others! */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
var mPass;
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default should be null",
|
||||
null,
|
||||
function () { return oSettings.fnInitComplete == null; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Two arguments passed (for Ajax!)",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = -1;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnInitComplete": function ( ) {
|
||||
mPass = arguments.length;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 2; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"That one argument is the settings object",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnInitComplete": function ( oSettings ) {
|
||||
mPass = oSettings;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return oTable.fnSettings() == mPass; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnInitComplete called once on first draw",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = 0;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnInitComplete": function ( ) {
|
||||
mPass++;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 1; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnInitComplete never called there after",
|
||||
function () {
|
||||
$('#example_next').click();
|
||||
$('#example_next').click();
|
||||
$('#example_next').click();
|
||||
},
|
||||
function () { return mPass == 1; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"10 rows in the table on complete",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = 0;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnInitComplete": function ( ) {
|
||||
mPass = $('#example tbody tr').length;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 10; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,118 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "fnRowCallback" );
|
||||
|
||||
/* Note - fnRowCallback MUST return the first arguments (modified or not) */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
var mPass;
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default should be null",
|
||||
null,
|
||||
function () { return oSettings.fnRowCallback == null; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Four arguments passed",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = -1;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnRowCallback": function ( nTr ) {
|
||||
mPass = arguments.length;
|
||||
return nTr;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 4; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRowCallback called once for each drawn row",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = 0;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
|
||||
mPass++;
|
||||
return nTr;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 10; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"fnRowCallback allows us to alter row information",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
|
||||
$(nTr).addClass('unit_test');
|
||||
return nTr;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(1)').hasClass('unit_test'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Data array has length matching columns",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = true;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
|
||||
if ( asData.length != 5 )
|
||||
mPass = false;
|
||||
return nTr;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Data array has length matching columns",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
|
||||
mPass = true;
|
||||
var iCount = 0;
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
|
||||
if ( iCount != iDrawIndex )
|
||||
mPass = false;
|
||||
iCount++;
|
||||
return nTr;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,68 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "fnServerData for Ajax sourced data" );
|
||||
|
||||
$(document).ready( function () {
|
||||
var mPass;
|
||||
|
||||
oTest.fnTest(
|
||||
"Argument length",
|
||||
function () {
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnServerData": function () {
|
||||
mPass = arguments.length;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass == 3; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Url",
|
||||
function () {
|
||||
$('#example').dataTable( {
|
||||
"bDestroy": true,
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnServerData": function (sUrl, aoData, fnCallback) {
|
||||
mPass = sUrl == "../../../examples/ajax/sources/arrays.txt";
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Data array",
|
||||
function () {
|
||||
$('#example').dataTable( {
|
||||
"bDestroy": true,
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnServerData": function (sUrl, aoData, fnCallback) {
|
||||
mPass = aoData.length==0;
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Callback function",
|
||||
function () {
|
||||
$('#example').dataTable( {
|
||||
"bDestroy": true,
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"fnServerData": function (sUrl, aoData, fnCallback) {
|
||||
mPass = typeof fnCallback == 'function';
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return mPass; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,85 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "iDisplayLength" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default length is ten",
|
||||
null,
|
||||
function () { return $('#example tbody tr').length == 10; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Select menu shows 10",
|
||||
null,
|
||||
function () { return $('#example_length select').val() == 10; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Set initial length to 25",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"iDisplayLength": 25
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr').length == 25; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Select menu shows 25",
|
||||
null,
|
||||
function () { return $('#example_length select').val() == 25; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Set initial length to 100",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"iDisplayLength": 100
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr').length == 57; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Select menu shows 25",
|
||||
null,
|
||||
function () { return $('#example_length select').val() == 100; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Set initial length to 23 (unknown select menu length)",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"iDisplayLength": 23
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr').length == 23; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Select menu shows 10 (since 23 is unknow)",
|
||||
null,
|
||||
function () { return $('#example_length select').val() == 10; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,86 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.oPaginate" );
|
||||
|
||||
/* Note that the paging language information only has relevence in full numbers */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sPaginationType": "full_numbers"
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"oLanguage.oPaginate defaults",
|
||||
null,
|
||||
function () {
|
||||
var bReturn =
|
||||
oSettings.oLanguage.oPaginate.sFirst == "First" &&
|
||||
oSettings.oLanguage.oPaginate.sPrevious == "Previous" &&
|
||||
oSettings.oLanguage.oPaginate.sNext == "Next" &&
|
||||
oSettings.oLanguage.oPaginate.sLast == "Last";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"oLanguage.oPaginate defaults are in the DOM",
|
||||
null,
|
||||
function () {
|
||||
var bReturn =
|
||||
$('#example_paginate .first').html() == "First" &&
|
||||
$('#example_paginate .previous').html() == "Previous" &&
|
||||
$('#example_paginate .next').html() == "Next" &&
|
||||
$('#example_paginate .last').html() == "Last";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"oLanguage.oPaginate can be defined",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sPaginationType": "full_numbers",
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sFirst": "unit1",
|
||||
"sPrevious": "test2",
|
||||
"sNext": "unit3",
|
||||
"sLast": "test4"
|
||||
}
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () {
|
||||
var bReturn =
|
||||
oSettings.oLanguage.oPaginate.sFirst == "unit1" &&
|
||||
oSettings.oLanguage.oPaginate.sPrevious == "test2" &&
|
||||
oSettings.oLanguage.oPaginate.sNext == "unit3" &&
|
||||
oSettings.oLanguage.oPaginate.sLast == "test4";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"oLanguage.oPaginate definitions are in the DOM",
|
||||
null,
|
||||
function () {
|
||||
var bReturn =
|
||||
$('#example_paginate .first').html() == "unit1" &&
|
||||
$('#example_paginate .previous').html() == "test2" &&
|
||||
$('#example_paginate .next').html() == "unit3" &&
|
||||
$('#example_paginate .last').html() == "test4";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,124 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sInfo" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info language is 'Showing _START_ to _END_ of _TOTAL_ entries' by default",
|
||||
null,
|
||||
function () { return oSettings.oLanguage.sInfo == "Showing _START_ to _END_ of _TOTAL_ entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Info language default is in the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info language can be defined - without any macros",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfo": "unit test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oLanguage.sInfo == "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Info language definition is in the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML = "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info language can be defined - with macro _START_ only",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfo": "unit _START_ test"
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML = "unit 1 test"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info language can be defined - with macro _END_ only",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfo": "unit _END_ test"
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML = "unit 10 test"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info language can be defined - with macro _TOTAL_ only",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfo": "unit _END_ test"
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML = "unit 57 test"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info language can be defined - with macros _START_ and _END_",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfo": "unit _START_ _END_ test"
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 test"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info language can be defined - with macros _START_, _END_ and _TOTAL_",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfo": "unit _START_ _END_ _TOTAL_ test"
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 57 test"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,82 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sInfoEmpty" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info empty language is 'Showing 0 to 0 of 0 entries' by default",
|
||||
function () { oTable.fnFilter("nothinghere"); },
|
||||
function () { return oSettings.oLanguage.sInfoEmpty == "Showing 0 to 0 of 0 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Info empty language default is in the DOM",
|
||||
null,
|
||||
function () {
|
||||
var bReturn = document.getElementById('example_info').innerHTML.replace(
|
||||
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) ==
|
||||
"Showing 0 to 0 of 0 entries";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info empty language can be defined",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfoEmpty": "unit test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
oTable.fnFilter("nothinghere");
|
||||
},
|
||||
function () { return oSettings.oLanguage.sInfoEmpty == "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Info empty language default is in the DOM",
|
||||
null,
|
||||
function () {
|
||||
var bReturn = document.getElementById('example_info').innerHTML.replace(
|
||||
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) ==
|
||||
"unit test";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Macro's not replaced",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfoEmpty": "unit _START_ _END_ _TOTAL_ test"
|
||||
}
|
||||
} );
|
||||
oTable.fnFilter("nothinghere");
|
||||
},
|
||||
function () {
|
||||
var bReturn = document.getElementById('example_info').innerHTML.replace(
|
||||
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) ==
|
||||
"unit _START_ _END_ _TOTAL_ test";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,82 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sInfoPostFix" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info post fix language is '' (blank) by default",
|
||||
null,
|
||||
function () { return oSettings.oLanguage.sInfoPostFix == ""; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Width no post fix, the basic info shows",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Info post fix language can be defined",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfoPostFix": "unit test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oLanguage.sInfoPostFix == "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Info empty language default is in the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit test"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Macros have no effect in the post fix",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfoPostFix": "unit _START_ _END_ _TOTAL_ test"
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit _START_ _END_ _TOTAL_ test"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Post fix is applied after fintering info",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sInfoPostFix": "unit test"
|
||||
}
|
||||
} );
|
||||
oTable.fnFilter("nothinghere");
|
||||
},
|
||||
function () { return document.getElementById('example_info').innerHTML = "Showing 0 to 0 of 0 entries unit (filtered from 57 total entries) test"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,110 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sLengthMenu" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Menu language is 'Show _MENU_ entries' by default",
|
||||
null,
|
||||
function () { return oSettings.oLanguage.sLengthMenu == "Show _MENU_ entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"_MENU_ macro is replaced by select menu in DOM",
|
||||
null,
|
||||
function () { return $('select', oSettings.aanFeatures.l[0]).length == 1 }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Default is put into DOM",
|
||||
null,
|
||||
function () {
|
||||
var anChildren = oSettings.aanFeatures.l[0].childNodes;
|
||||
var bReturn =
|
||||
anChildren[0].nodeValue == "Show " &&
|
||||
anChildren[2].nodeValue == " entries";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Menu length language can be defined - no _MENU_ macro",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sLengthMenu": "unit test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oLanguage.sLengthMenu == "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Menu length language definition is in the DOM",
|
||||
null,
|
||||
function () {
|
||||
var anChildren = oSettings.aanFeatures.l[0].childNodes;
|
||||
return anChildren[0].nodeValue == "unit test";
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Menu length language can be defined - with _MENU_ macro",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sLengthMenu": "unit _MENU_ test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () {
|
||||
var anChildren = oSettings.aanFeatures.l[0].childNodes;
|
||||
var bReturn =
|
||||
anChildren[0].nodeValue == "unit " &&
|
||||
anChildren[2].nodeValue == " test";
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Only the _MENU_ macro",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sLengthMenu": "_MENU_"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () {
|
||||
var anChildren = oSettings.aanFeatures.l[0].childNodes;
|
||||
var bReturn =
|
||||
anChildren.length == 1 &&
|
||||
$('select', oSettings.aanFeatures.l[0]).length == 1;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,51 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sProcessing" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bProcessing": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing language is 'Processing...' by default",
|
||||
null,
|
||||
function () { return oSettings.oLanguage.sProcessing == "Processing..."; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Processing language default is in the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_processing').innerHTML = "Processing..."; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Processing language can be defined",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"bProcessing": true,
|
||||
"oLanguage": {
|
||||
"sProcessing": "unit test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oLanguage.sProcessing == "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Processing language definition is in the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_processing').innerHTML = "unit test"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,68 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sSearch" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search language is 'Search:' by default",
|
||||
null,
|
||||
function () { return oSettings.oLanguage.sSearch == "Search:"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Search language default is in the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_filter').childNodes[0].nodeValue
|
||||
== "Search: "; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search language can be defined",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sSearch": "unit test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oLanguage.sSearch == "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Info language definition is in the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_filter').childNodes[0].nodeValue
|
||||
== "unit test "; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Blank search has a no space (separator) inserted",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sSearch": ""
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return document.getElementById('example_filter').childNodes.length == 1; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,64 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sUrl" );
|
||||
|
||||
/* Note that we only test the internal storage of language information pulled form a file here
|
||||
* as the other language tests will check it goes into the DOM correctly
|
||||
*/
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnTest(
|
||||
"sUrl is blank by default",
|
||||
null,
|
||||
function () { return oSettings.oLanguage.sUrl == ""; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Loading of German file loads language information",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sUrl": "../../../examples/examples_support/de_DE.txt"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () {
|
||||
var bReturn =
|
||||
oSettings.oLanguage.sProcessing == "Bitte warten..." &&
|
||||
oSettings.oLanguage.sLengthMenu == "_MENU_ Einträge anzeigen" &&
|
||||
oSettings.oLanguage.sZeroRecords == "Keine Einträge vorhanden." &&
|
||||
oSettings.oLanguage.sInfo == "_START_ bis _END_ von _TOTAL_ Einträgen" &&
|
||||
oSettings.oLanguage.sInfoEmpty == "0 bis 0 von 0 Einträgen" &&
|
||||
oSettings.oLanguage.sInfoFiltered == "(gefiltert von _MAX_ Einträgen)" &&
|
||||
oSettings.oLanguage.sInfoPostFix == "" &&
|
||||
oSettings.oLanguage.sSearch == "Suchen" &&
|
||||
oSettings.oLanguage.oPaginate.sFirst == "Erster" &&
|
||||
oSettings.oLanguage.oPaginate.sPrevious == "Zurück" &&
|
||||
oSettings.oLanguage.oPaginate.sNext == "Nächster" &&
|
||||
oSettings.oLanguage.oPaginate.sLast == "Letzter";
|
||||
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
/* One DOM check just to ensure that they go into the DOM */
|
||||
oTest.fnTest(
|
||||
"Loaded language goes into the DOM",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML = "1 bis 10 von 57 Einträgen"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,50 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oLanguage.sZeroRecords" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Zero records language is 'No matching records found' by default",
|
||||
null,
|
||||
function () { return oSettings.oLanguage.sZeroRecords == "No matching records found"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Text is shown when empty table (after filtering)",
|
||||
function () { oTable.fnFilter('nothinghere'); },
|
||||
function () { return $('#example tbody tr td')[0].innerHTML == "No matching records found" }
|
||||
);
|
||||
|
||||
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Zero records language can be defined",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oLanguage": {
|
||||
"sZeroRecords": "unit test"
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.oLanguage.sZeroRecords == "unit test"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Text is shown when empty table (after filtering)",
|
||||
function () { oTable.fnFilter('nothinghere2'); },
|
||||
function () { return $('#example tbody tr td')[0].innerHTML == "unit test" }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
114
media/unit_testing/tests_onhold/6_delayed_rendering/oSearch.js
Normal file
114
media/unit_testing/tests_onhold/6_delayed_rendering/oSearch.js
Normal file
@ -0,0 +1,114 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "oSearch" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default values should be blank",
|
||||
null,
|
||||
function () {
|
||||
var bReturn = oSettings.oPreviousSearch.sSearch == "" &&
|
||||
!oSettings.oPreviousSearch.bRegex;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
/* This test might be considered iffy since the full object isn't given, but it's reasonable to
|
||||
* expect DataTables to cope with this. It should just assumine regex false
|
||||
*/
|
||||
oTest.fnWaitTest(
|
||||
"Search term only in object",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oSearch": {
|
||||
"sSearch": "Mozilla"
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"New search will kill old one",
|
||||
function () {
|
||||
oTable.fnFilter("Opera");
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search plain text term and escape regex true",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oSearch": {
|
||||
"sSearch": "DS",
|
||||
"bRegex": false
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search plain text term and escape regex false",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oSearch": {
|
||||
"sSearch": "Opera",
|
||||
"bRegex": true
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search regex text term and escape regex true",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oSearch": {
|
||||
"sSearch": "1.*",
|
||||
"bRegex": false
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Search regex text term and escape regex false",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"oSearch": {
|
||||
"sSearch": "1.*",
|
||||
"bRegex": true
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,140 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "Custom data source property - property given" );
|
||||
|
||||
|
||||
$(document).ready( function () {
|
||||
var oInit = {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/custom_prop.txt",
|
||||
"bDeferRender": true,
|
||||
"sAjaxDataProp": "test"
|
||||
};
|
||||
$('#example').dataTable( oInit );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"10 rows shown on the first page",
|
||||
null,
|
||||
function () { return $('#example tbody tr').length == 10; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Initial sort occured",
|
||||
null,
|
||||
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
/* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
|
||||
oTest.fnTest(
|
||||
"Sorting (first click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (second click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (third click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (first click) on numeric column",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "-"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (second click) on numeric column",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting multi-column (first click)",
|
||||
function () {
|
||||
$('#example thead th:eq(0)').click();
|
||||
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
|
||||
function () { var b =
|
||||
$('#example tbody td:eq(0)').html() == "Gecko" &&
|
||||
$('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting multi-column - sorting second column only",
|
||||
function () {
|
||||
$('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
/* Basic paging */
|
||||
oTest.fnTest(
|
||||
"Paging to second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Paging to first page",
|
||||
function () { $('#example_previous').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Attempting to page back beyond the first page",
|
||||
function () { $('#example_previous').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
/* Changing length */
|
||||
oTest.fnTest(
|
||||
"Changing table length to 25 records",
|
||||
function () { $("select[name=example_length]").val('25').change(); },
|
||||
function () { return $('#example tbody tr').length == 25; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 50 records",
|
||||
function () { $("select[name=example_length]").val('50').change(); },
|
||||
function () { return $('#example tbody tr').length == 50; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 100 records",
|
||||
function () { $("select[name=example_length]").val('100').change(); },
|
||||
function () { return $('#example tbody tr').length == 57; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 10 records",
|
||||
function () { $("select[name=example_length]").val('10').change(); },
|
||||
function () { return $('#example tbody tr').length == 10; }
|
||||
);
|
||||
|
||||
/*
|
||||
* Information element
|
||||
*/
|
||||
oTest.fnTest(
|
||||
"Information on zero config",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information on second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information on third page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,140 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "Custom data source property - array only" );
|
||||
|
||||
|
||||
$(document).ready( function () {
|
||||
var oInit = {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/array_only.txt",
|
||||
"bDeferRender": true,
|
||||
"sAjaxDataProp": ""
|
||||
};
|
||||
$('#example').dataTable( oInit );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"10 rows shown on the first page",
|
||||
null,
|
||||
function () { return $('#example tbody tr').length == 10; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Initial sort occured",
|
||||
null,
|
||||
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
|
||||
);
|
||||
|
||||
/* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
|
||||
oTest.fnTest(
|
||||
"Sorting (first click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (second click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (third click) on second column",
|
||||
function () { $('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (first click) on numeric column",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "-"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting (second click) on numeric column",
|
||||
function () { $('#example thead th:eq(3)').click(); },
|
||||
function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting multi-column (first click)",
|
||||
function () {
|
||||
$('#example thead th:eq(0)').click();
|
||||
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
|
||||
function () { var b =
|
||||
$('#example tbody td:eq(0)').html() == "Gecko" &&
|
||||
$('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Sorting multi-column - sorting second column only",
|
||||
function () {
|
||||
$('#example thead th:eq(1)').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
/* Basic paging */
|
||||
oTest.fnTest(
|
||||
"Paging to second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Paging to first page",
|
||||
function () { $('#example_previous').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Attempting to page back beyond the first page",
|
||||
function () { $('#example_previous').click(); },
|
||||
function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
||||
);
|
||||
|
||||
/* Changing length */
|
||||
oTest.fnTest(
|
||||
"Changing table length to 25 records",
|
||||
function () { $("select[name=example_length]").val('25').change(); },
|
||||
function () { return $('#example tbody tr').length == 25; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 50 records",
|
||||
function () { $("select[name=example_length]").val('50').change(); },
|
||||
function () { return $('#example tbody tr').length == 50; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 100 records",
|
||||
function () { $("select[name=example_length]").val('100').change(); },
|
||||
function () { return $('#example tbody tr').length == 57; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Changing table length to 10 records",
|
||||
function () { $("select[name=example_length]").val('10').change(); },
|
||||
function () { return $('#example tbody tr').length == 10; }
|
||||
);
|
||||
|
||||
/*
|
||||
* Information element
|
||||
*/
|
||||
oTest.fnTest(
|
||||
"Information on zero config",
|
||||
null,
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information on second page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Information on third page",
|
||||
function () { $('#example_next').click(); },
|
||||
function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,23 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "sAjaxSource" );
|
||||
|
||||
/* Sanitfy check really - all the other tests blast this */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Server side is off by default",
|
||||
null,
|
||||
function () {
|
||||
return oSettings.sAjaxSource == "../../../examples/ajax/sources/arrays.txt";
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
269
media/unit_testing/tests_onhold/6_delayed_rendering/sDom.js
Normal file
269
media/unit_testing/tests_onhold/6_delayed_rendering/sDom.js
Normal file
@ -0,0 +1,269 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "sDom" );
|
||||
|
||||
/* This is going to be brutal on the browser! There is a lot that can be tested here... */
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default DOM varaible",
|
||||
null,
|
||||
function () { return oSettings.sDom == "lfrtip"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Default DOM in document",
|
||||
null,
|
||||
function () {
|
||||
var nNodes = $('#demo div, #demo table');
|
||||
var nWrapper = document.getElementById('example_wrapper');
|
||||
var nLength = document.getElementById('example_length');
|
||||
var nFilter = document.getElementById('example_filter');
|
||||
var nInfo = document.getElementById('example_info');
|
||||
var nPaging = document.getElementById('example_paginate');
|
||||
var nTable = document.getElementById('example');
|
||||
|
||||
var bReturn =
|
||||
nNodes[0] == nWrapper &&
|
||||
nNodes[1] == nLength &&
|
||||
nNodes[2] == nFilter &&
|
||||
nNodes[3] == nTable &&
|
||||
nNodes[4] == nInfo &&
|
||||
nNodes[5] == nPaging;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check example 1 in code propagates",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sDom": '<"wrapper"flipt>'
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () { return oSettings.sDom == '<"wrapper"flipt>'; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check example 1 in DOM",
|
||||
null,
|
||||
function () {
|
||||
var jqNodes = $('#demo div, #demo table');
|
||||
var nNodes = [];
|
||||
|
||||
/* Strip the paging nodes */
|
||||
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( jqNodes[i].getAttribute('id') != "example_previous" &&
|
||||
jqNodes[i].getAttribute('id') != "example_next" )
|
||||
{
|
||||
nNodes.push( jqNodes[i] );
|
||||
}
|
||||
}
|
||||
|
||||
var nWrapper = document.getElementById('example_wrapper');
|
||||
var nLength = document.getElementById('example_length');
|
||||
var nFilter = document.getElementById('example_filter');
|
||||
var nInfo = document.getElementById('example_info');
|
||||
var nPaging = document.getElementById('example_paginate');
|
||||
var nTable = document.getElementById('example');
|
||||
var nCustomWrapper = $('div.wrapper')[0];
|
||||
|
||||
var bReturn =
|
||||
nNodes[0] == nWrapper &&
|
||||
nNodes[1] == nCustomWrapper &&
|
||||
nNodes[2] == nFilter &&
|
||||
nNodes[3] == nLength &&
|
||||
nNodes[4] == nInfo &&
|
||||
nNodes[5] == nPaging &&
|
||||
nNodes[6] == nTable;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check example 2 in DOM",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sDom": '<lf<t>ip>'
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var jqNodes = $('#demo div, #demo table');
|
||||
var nNodes = [];
|
||||
var nCustomWrappers = []
|
||||
|
||||
/* Strip the paging nodes */
|
||||
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( jqNodes[i].getAttribute('id') != "example_previous" &&
|
||||
jqNodes[i].getAttribute('id') != "example_next" )
|
||||
{
|
||||
nNodes.push( jqNodes[i] );
|
||||
}
|
||||
|
||||
/* Only the two custom divs don't have class names */
|
||||
if ( !jqNodes[i].getAttribute('class') )
|
||||
{
|
||||
nCustomWrappers.push( jqNodes[i] );
|
||||
}
|
||||
}
|
||||
|
||||
var nWrapper = document.getElementById('example_wrapper');
|
||||
var nLength = document.getElementById('example_length');
|
||||
var nFilter = document.getElementById('example_filter');
|
||||
var nInfo = document.getElementById('example_info');
|
||||
var nPaging = document.getElementById('example_paginate');
|
||||
var nTable = document.getElementById('example');
|
||||
|
||||
var bReturn =
|
||||
nNodes[0] == nWrapper &&
|
||||
nNodes[1] == nCustomWrappers[0] &&
|
||||
nNodes[2] == nLength &&
|
||||
nNodes[3] == nFilter &&
|
||||
nNodes[4] == nCustomWrappers[1] &&
|
||||
nNodes[5] == nTable &&
|
||||
nNodes[6] == nInfo &&
|
||||
nNodes[7] == nPaging;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check no length element",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sDom": 'frtip'
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var nNodes = $('#demo div, #demo table');
|
||||
var nWrapper = document.getElementById('example_wrapper');
|
||||
var nLength = document.getElementById('example_length');
|
||||
var nFilter = document.getElementById('example_filter');
|
||||
var nInfo = document.getElementById('example_info');
|
||||
var nPaging = document.getElementById('example_paginate');
|
||||
var nTable = document.getElementById('example');
|
||||
|
||||
var bReturn =
|
||||
nNodes[0] == nWrapper &&
|
||||
null == nLength &&
|
||||
nNodes[1] == nFilter &&
|
||||
nNodes[2] == nTable &&
|
||||
nNodes[3] == nInfo &&
|
||||
nNodes[4] == nPaging;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check no filter element",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sDom": 'lrtip'
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var nNodes = $('#demo div, #demo table');
|
||||
var nWrapper = document.getElementById('example_wrapper');
|
||||
var nLength = document.getElementById('example_length');
|
||||
var nFilter = document.getElementById('example_filter');
|
||||
var nInfo = document.getElementById('example_info');
|
||||
var nPaging = document.getElementById('example_paginate');
|
||||
var nTable = document.getElementById('example');
|
||||
|
||||
var bReturn =
|
||||
nNodes[0] == nWrapper &&
|
||||
nNodes[1] == nLength &&
|
||||
null == nFilter &&
|
||||
nNodes[2] == nTable &&
|
||||
nNodes[3] == nInfo &&
|
||||
nNodes[4] == nPaging;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
/* Note we don't test for no table as this is not supported (and it would be fairly daft! */
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check no info element",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sDom": 'lfrtp'
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var nNodes = $('#demo div, #demo table');
|
||||
var nWrapper = document.getElementById('example_wrapper');
|
||||
var nLength = document.getElementById('example_length');
|
||||
var nFilter = document.getElementById('example_filter');
|
||||
var nInfo = document.getElementById('example_info');
|
||||
var nPaging = document.getElementById('example_paginate');
|
||||
var nTable = document.getElementById('example');
|
||||
|
||||
var bReturn =
|
||||
nNodes[0] == nWrapper &&
|
||||
nNodes[1] == nLength &&
|
||||
nNodes[2] == nFilter &&
|
||||
nNodes[3] == nTable &&
|
||||
null == nInfo &&
|
||||
nNodes[4] == nPaging;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check no paging element",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
$('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sDom": 'lfrti'
|
||||
} );
|
||||
},
|
||||
function () {
|
||||
var nNodes = $('#demo div, #demo table');
|
||||
var nWrapper = document.getElementById('example_wrapper');
|
||||
var nLength = document.getElementById('example_length');
|
||||
var nFilter = document.getElementById('example_filter');
|
||||
var nInfo = document.getElementById('example_info');
|
||||
var nPaging = document.getElementById('example_paginate');
|
||||
var nTable = document.getElementById('example');
|
||||
|
||||
var bReturn =
|
||||
nNodes[0] == nWrapper &&
|
||||
nNodes[1] == nLength &&
|
||||
nNodes[2] == nFilter &&
|
||||
nNodes[3] == nTable &&
|
||||
nNodes[4] == nInfo &&
|
||||
null == nPaging;
|
||||
return bReturn;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
@ -0,0 +1,136 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "sPaginationType" );
|
||||
|
||||
$(document).ready( function () {
|
||||
/* Check the default */
|
||||
var oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true
|
||||
} );
|
||||
var oSettings = oTable.fnSettings();
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check two button paging is the default",
|
||||
null,
|
||||
function () { return oSettings.sPaginationType == "two_button"; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check class is applied",
|
||||
null,
|
||||
function () { return $('#example_paginate').hasClass('paging_two_button'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Two div elements are in the wrapper",
|
||||
null,
|
||||
function () { return $('#example_paginate div').length == 2; }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"We have the previous button",
|
||||
null,
|
||||
function () { return document.getElementById('example_previous'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"We have the next button",
|
||||
null,
|
||||
function () { return document.getElementById('example_next'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Previous button is disabled",
|
||||
null,
|
||||
function () { return $('#example_previous').hasClass('paginate_disabled_previous'); }
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Next button is enabled",
|
||||
null,
|
||||
function () { return $('#example_next').hasClass('paginate_enabled_next'); }
|
||||
);
|
||||
|
||||
/* Don't test paging - that's done by the zero config test script. */
|
||||
|
||||
|
||||
/* Two buttons paging */
|
||||
var bComplete = false;
|
||||
oTest.fnWaitTest(
|
||||
"Can enabled full numbers paging",
|
||||
function () {
|
||||
oSession.fnRestore();
|
||||
oTable = $('#example').dataTable( {
|
||||
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
||||
"bDeferRender": true,
|
||||
"sPaginationType": "full_numbers",
|
||||
"fnInitComplete": function () {
|
||||
bComplete = true;
|
||||
}
|
||||
} );
|
||||
oSettings = oTable.fnSettings();
|
||||
},
|
||||
function () {
|
||||
if ( bComplete )
|
||||
return oSettings.sPaginationType == "full_numbers";
|
||||
else
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check full numbers class is applied",
|
||||
null,
|
||||
function () { return $('#example_paginate').hasClass('paging_full_numbers'); }
|
||||
);
|
||||
|
||||
|
||||
var nFirst, nPrevious, nNext, nLast;
|
||||
oTest.fnWaitTest(
|
||||
"Jump to last page",
|
||||
function () {
|
||||
nFirst = $('div.dataTables_paginate span.first');
|
||||
nPrevious = $('div.dataTables_paginate span.previous');
|
||||
nNext = $('div.dataTables_paginate span.next');
|
||||
nLast = $('div.dataTables_paginate span.last');
|
||||
nLast.click();
|
||||
},
|
||||
function () {
|
||||
return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries";
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Go to two pages previous",
|
||||
function () {
|
||||
nPrevious.click();
|
||||
nPrevious.click();
|
||||
},
|
||||
function () {
|
||||
return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries";
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Next (second last) page",
|
||||
function () {
|
||||
nNext.click();
|
||||
},
|
||||
function () {
|
||||
return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries";
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Jump to first page",
|
||||
function () {
|
||||
nFirst.click();
|
||||
},
|
||||
function () {
|
||||
return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries";
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
Loading…
x
Reference in New Issue
Block a user