Вход Регистрация
Файл: datatables/media/unit_testing/tests_onhold/2_js/aoColumns.fnRender.js
Строк: 163
<?php
// DATA_TEMPLATE: js_data
oTest.fnStart"aoColumns.fnRender" );

$(
document).ready( function () {
    
/* Check the default */
    
var mTmp 0;
    var 
oTable = $('#example').dataTable( {
        
"aaData"gaaData,
        
"aoColumns": [
            
null,
            { 
"fnRender": function (a) {
                
mTmp++;
                return 
a.aData[a.iDataColumn];
            } },
            
null,
            
null,
            
null
        
]
    } );
    var 
oSettings oTable.fnSettings();
    
    
oTest.fnTest
        
"Single column - fnRender is called once for each row",
        
null,
        function () { return 
mTmp == 57; }
    );
    
    
oTest.fnTest
        
"Confirm that fnRender passes two arguments with four parameters",
        function () {
            
mTmp true;
            
oSession.fnRestore();
            
oTable = $('#example').dataTable( {
                
"aaData"gaaData,
                
"aoColumns": [
                    
null,
                    { 
"fnRender": function (a) {
                        if ( 
arguments.length != || typeof a.iDataRow=='undefined' ||
                             
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ||
                             
typeof a.mDataProp=='undefined' )
                        {
                            
mTmp false;
                        }
                        return 
a.aData[a.iDataColumn];
                    } },
                    
null,
                    
null,
                    
null
                
]
            } );
        },
        function () { return 
mTmp; }
    );
    
    
oTest.fnTest
        
"fnRender iDataColumn is the column",
        function () {
            
mTmp true;
            
oSession.fnRestore();
            
oTable = $('#example').dataTable( {
                
"aaData"gaaData,
                
"aoColumns": [
                    
null,
                    { 
"fnRender": function (a) {
                        if ( 
a.iDataColumn != )
                        {
                            
mTmp false;
                        }
                        return 
a.aData[a.iDataColumn];
                    } },
                    
null,
                    
null,
                    
null
                
]
            } );
        },
        function () { return 
mTmp; }
    );
    
    
oTest.fnTest
        
"fnRender aData is data array of correct size",
        function () {
            
mTmp true;
            
oSession.fnRestore();
            
oTable = $('#example').dataTable( {
                
"aaData"gaaData,
                
"aoColumns": [
                    
null,
                    { 
"fnRender": function (a) {
                        if ( 
a.aData.length != )
                        {
                            
mTmp false;
                        }
                        return 
a.aData[a.iDataColumn];
                    } },
                    
null,
                    
null,
                    
null
                
]
            } );
        },
        function () { return 
mTmp; }
    );
    
    
oTest.fnTest
        
"Passed back data is put into the DOM",
        function () {
            
oSession.fnRestore();
            
oTable = $('#example').dataTable( {
                
"aaData"gaaData,
                
"aoColumns": [
                    
null,
                    { 
"fnRender": function (a) {
                        return 
'unittest';
                    } },
                    
null,
                    
null,
                    
null
                
]
            } );
        },
        function () { return $(
'#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; }
    );
    
    
oTest.fnTest
        
"Passed back data is put into the DOM",
        function () {
            
oSession.fnRestore();
            
oTable = $('#example').dataTable( {
                
"aaData"gaaData,
                
"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();
} );
?>
Онлайн: 1
Реклама