1/* eslint-env qunit */ 2 3window.tablelayout = window.tablelayout || {}; 4 5(function (tablelayout) { 6 'use strict'; 7 8 QUnit.module( 'Tests for tablelayout.floatTable' ); 9 QUnit.test('float table right', function(assert) { 10 var $fixture = jQuery( '#qunit-fixture' ).find('#smallTable'); 11 var $table = $fixture.find( 'table' ); 12 var expected_html = '<div class="floatwrapper right"><div class="plugin_tablelayout_placeholder" data-tablelayout="0"></div><div class="table sectionedit8"><table class="inline"> ' + 13 '<thead> ' + 14 '<tr class="row0"> ' + 15 ' <th class="col0 leftalign"> Column 1 </th><th class="col1 leftalign"> Column 2 </th> ' + 16 '</tr> ' + 17 '<tr class="row1"> ' + 18 ' <th class="col0 leftalign"> 2 </th><th class="col1 leftalign"> T </th> ' + 19 '</tr> ' + 20 '</thead> ' + 21 '<tbody><tr class="row2"> ' + 22 ' <td class="col0 leftalign"> 3 </td><td class="col1 leftalign"> v </td> ' + 23 '</tr> ' + 24 '<tr class="row3"> ' + 25 ' <th class="col0 leftalign"> 4 </th><th class="col1 leftalign"> A </th> ' + 26 '</tr> ' + 27 '<tr class="row4"> ' + 28 ' <td class="col0 leftalign"> 5 </td><td class="col1 leftalign"> b </td> ' + 29 '</tr> ' + 30 '</tbody></table></div><div class="secedit editbutton_table editbutton_2" style="display: block; margin-top: -12px;"></div></div>'; 31 tablelayout.floatTable($table, 'right'); 32 var actual_html = $fixture.html().replace(/\s\s+/g, ' ').trim(); 33 34 assert.deepEqual(actual_html, expected_html.replace(/\s\s+/g, ' ').trim(), 'html is ok'); 35 }); 36 37 38 QUnit.test('float table center', function(assert) { 39 var $fixture = jQuery( '#qunit-fixture' ).find('#smallTable'); 40 var $table = $fixture.find( 'table' ); 41 var expected_html = '<div class="floatwrapper center"><div class="plugin_tablelayout_placeholder" data-tablelayout="0"></div><div class="table sectionedit8"><table class="inline"> ' + 42 '<thead> ' + 43 '<tr class="row0"> ' + 44 ' <th class="col0 leftalign"> Column 1 </th><th class="col1 leftalign"> Column 2 </th> ' + 45 '</tr> ' + 46 '<tr class="row1"> ' + 47 ' <th class="col0 leftalign"> 2 </th><th class="col1 leftalign"> T </th> ' + 48 '</tr> ' + 49 '</thead> ' + 50 '<tbody><tr class="row2"> ' + 51 ' <td class="col0 leftalign"> 3 </td><td class="col1 leftalign"> v </td> ' + 52 '</tr> ' + 53 '<tr class="row3"> ' + 54 ' <th class="col0 leftalign"> 4 </th><th class="col1 leftalign"> A </th> ' + 55 '</tr> ' + 56 '<tr class="row4"> ' + 57 ' <td class="col0 leftalign"> 5 </td><td class="col1 leftalign"> b </td> ' + 58 '</tr> ' + 59 '</tbody></table></div><div class="secedit editbutton_table editbutton_2" style="display: block; margin-top: -12px;"></div></div>'; 60 tablelayout.floatTable($table, 'center'); 61 var actual_html = $fixture.html().replace(/\s\s+/g, ' ').trim(); 62 63 assert.deepEqual(actual_html, expected_html.replace(/\s\s+/g, ' ').trim(), 'html is ok'); 64 }); 65 66}(window.tablelayout)); 67