X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webapp%2Fresources%2Fdatatables-1.9.4%2Fmedia%2Funit_testing%2Ftests_onhold%2F2_js%2FaoColumns.sWidth.js;fp=webapp%2Fresources%2Fdatatables-1.9.4%2Fmedia%2Funit_testing%2Ftests_onhold%2F2_js%2FaoColumns.sWidth.js;h=960c0561efc8415f2149ca35e031757998b8fe1a;hb=9bb6ee99ca7f738fac1087190b5481b8fe6e8d9f;hp=0000000000000000000000000000000000000000;hpb=2e3f6b76be585306f1003d849831840c0adb3360;p=proteocache.git diff --git a/webapp/resources/datatables-1.9.4/media/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js b/webapp/resources/datatables-1.9.4/media/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js new file mode 100755 index 0000000..960c056 --- /dev/null +++ b/webapp/resources/datatables-1.9.4/media/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js @@ -0,0 +1,87 @@ +// DATA_TEMPLATE: js_data +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( { + "aaData": gaaData, + "bAutoWidth": false, + "aoColumns": [ + null, + { "sWidth": '40%' }, + null, + null, + null + ] + } ); + var oSettings = oTable.fnSettings(); + + oTest.fnTest( + "With auto width disabled the width for one column is appled", + null, + function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; } + ); + + oTest.fnTest( + "With auto width disabled the width for one column is appled", + function () { + oSession.fnRestore(); + oTable = $('#example').dataTable( { + "aaData": gaaData, + "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.fnTest( + "With auto width, it will make the smallest column the largest with percentage width given", + function () { + oSession.fnRestore(); + oTable = $('#example').dataTable( { + "aaData": gaaData, + "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(); +} ); \ No newline at end of file