1/* eslint-env qunit */
2
3window.tablelayout = window.tablelayout || {};
4
5(function (tablelayout) {
6    'use strict';
7
8    QUnit.module( 'Tests for tablelayout.sortTable' );
9    QUnit.test('sort desc', function(assert) {
10        var $fixture = jQuery( '#qunit-fixture' ).find('#smallTable');
11        var $tableRows = $fixture.find( 'table tr' ).slice(1);
12        var $actualSortedRows = tablelayout.sortTable($tableRows, 0, 'desc');
13
14        var expectedClasses = ['row4', 'row3', 'row2', 'row1'];
15        expectedClasses.forEach(function (expectedClassName, index) {
16            assert.equal($actualSortedRows[index].className, expectedClassName);
17        });
18    });
19
20
21    QUnit.test('sort asc', function(assert) {
22        var $fixture = jQuery( '#qunit-fixture' ).find('#smallTable');
23        var $tableRows = $fixture.find( 'table tr' ).slice(1);
24        var $actualSortedRows = tablelayout.sortTable($tableRows, 1, 'asc');
25
26        var expectedClasses = ['row3', 'row4', 'row1', 'row2'];
27        expectedClasses.forEach(function (expectedClassName, index) {
28            assert.equal($actualSortedRows[index].className, expectedClassName);
29        });
30    });
31
32}(window.tablelayout));
33