/* eslint-env qunit */ window.tablelayout = window.tablelayout || {}; (function (tablelayout) { 'use strict'; QUnit.module( 'Tests for tablelayout.styleColumnWidths' ); QUnit.test('float style both rows', function(assert) { var $fixture = jQuery( '#qunit-fixture' ).find('#smallTable'); var $table = $fixture.find( 'table' ); var expected_html = '
' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + '
Column 1 Column 2
2 T
3 v
4 A
5 b
'; tablelayout.styleColumnWidths($table, ['80px', '80px']); var actual_html = $fixture.html().replace(/\s\s+/g, ' ').trim(); assert.deepEqual(actual_html, expected_html.replace(/\s\s+/g, ' ').trim(), 'html is ok'); }); QUnit.test('float style first row only', function(assert) { var $fixture = jQuery( '#qunit-fixture' ).find('#smallTable'); var $table = $fixture.find( 'table' ); var expected_html = '
' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + '
Column 1 Column 2
2 T
3 v
4 A
5 b
'; tablelayout.styleColumnWidths($table, ['80px']); var actual_html = $fixture.html().replace(/\s\s+/g, ' ').trim(); assert.deepEqual(actual_html, expected_html.replace(/\s\s+/g, ' ').trim(), 'html is ok'); }); QUnit.test('number of table columns', function(assert) { var $table = jQuery( '#qunit-fixture' ).find('#smallTable').find( 'table' ); var actual_number = tablelayout.getNumberOfTableCols($table); var expected_number = 2; assert.equal(actual_number, expected_number, 'number of columns correctly counted'); }); }(window.tablelayout));