From e28f7b52cde9a22a64fa6e83a52f2f9c6da41249 Mon Sep 17 00:00:00 2001 From: Mottie Date: Mon, 10 Aug 2015 19:18:43 -0500 Subject: [PATCH] testing: cleanup --- Gruntfile.js | 2 +- testing/testing-widgets.js | 8 ++--- testing/testing.css | 5 --- testing/testing.js | 66 ++++++++++++++++++-------------------- 4 files changed, 36 insertions(+), 45 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 7ee6ebff..26e0a9a5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -407,7 +407,7 @@ module.exports = function( grunt ) { grunt.task.run(tasks); }); - // update bower.json & tablesorter.jquery.json file version numbers to match the package.json version + // update tablesorter.jquery.json file version numbers to match the package.json version grunt.registerTask( 'updateManifest', function() { var i, project, projectFile = [ 'tablesorter.jquery.json' ], diff --git a/testing/testing-widgets.js b/testing/testing-widgets.js index f4312ccd..869ddc19 100644 --- a/testing/testing-widgets.js +++ b/testing/testing-widgets.js @@ -1,9 +1,7 @@ -/*! +/*! * TableSorter QUnit Testing - filter widget */ /*jshint unused: false */ -/*global start: false, asyncTest: false, equal: false, $: false, expect: false, module: false, - tester: false, test: false, stop: false */ /* Filter widget tested parts @@ -40,8 +38,8 @@ EVENTS: filterStart */ -$(function(){ - module('Widgets', { +jQuery(function($){ + QUnit.module('Widgets', { beforeEach: function(assert) { this.ts = $.tablesorter; diff --git a/testing/testing.css b/testing/testing.css index 6e5bb1c3..58ac9e6e 100644 --- a/testing/testing.css +++ b/testing/testing.css @@ -3,8 +3,3 @@ position: absolute; top: -999em; } - -/* skipped tests */ -#qunit-tests li.pass.skipped { - background-color: #fffacd; -} diff --git a/testing/testing.js b/testing/testing.js index 5da89a93..f7895d11 100644 --- a/testing/testing.js +++ b/testing/testing.js @@ -2,9 +2,7 @@ * TableSorter QUnit Testing */ /*jshint unused: false */ -/*global QUnit: false, JSHINT: false, ok: false, start: false, deepEqual: false, asyncTest: false, - strictEqual: false, jQuery: false, equal: false, $: false, expect: false, module: false, - test: false, stop: false, ipv6tests: false */ +/*global QUnit: false, jQuery: false, ipv6tests: false */ // Accepts a function with a single argument -- deferred object, which should be resolved at some point in a function. // Returns a promise, wrapping this function call. @@ -137,7 +135,7 @@ EVENTS: - */ -$(function(){ +jQuery(function($){ var ts = $.tablesorter, $table1 = $('#table1'), @@ -213,7 +211,7 @@ $(function(){ $table5.tablesorter(); - module('core'); + QUnit.module('core'); /************************************************ Initialization ************************************************/ @@ -251,24 +249,24 @@ $(function(){ var d = ts.isDigit; QUnit.test( 'isDigit', function(assert) { assert.expect(18); - ok( d('-1'), 'allow negative (-1)'); - ok( d('+1'), 'allow plus (+1)'); - ok( d('(1)'), 'allow parenthesis (1)'); - ok( d('123'), "string has numbers ('123')"); - ok( d(123), 'has numbers (123)'); - ok( d('1.2'), 'remove decimal (1.2)'); - ok( d('1,234'),'remove commas (1,234)'); - ok( d("11'"), "remove apostrophe's (11')"); // 11 feet - ok( d('3\'4"'),"remove quotes (3'4\")"); // 3 foot 4 inches - ok( d(' 12 '), 'remove spaces ( 12 )'); - ok( !d('x'), 'non-digit alphabet'); - ok( !d('1x'), 'digit + alphabet'); - ok( !d('x1'), 'alphabet + digit'); - ok( !d('@'), 'non-digit symbols'); - ok( !d('1-'), 'negative after (1-) not allowed?'); - ok( !d('1+'), 'plus after (1+) not allowed?'); - ok( !d('$2'), 'no money; the currency parser will catch these'); - ok( !d(''), "empty string ('')"); + assert.ok( d('-1'), 'allow negative (-1)'); + assert.ok( d('+1'), 'allow plus (+1)'); + assert.ok( d('(1)'), 'allow parenthesis (1)'); + assert.ok( d('123'), "string has numbers ('123')"); + assert.ok( d(123), 'has numbers (123)'); + assert.ok( d('1.2'), 'remove decimal (1.2)'); + assert.ok( d('1,234'),'remove commas (1,234)'); + assert.ok( d("11'"), "remove apostrophe's (11')"); // 11 feet + assert.ok( d('3\'4"'),"remove quotes (3'4\")"); // 3 foot 4 inches + assert.ok( d(' 12 '), 'remove spaces ( 12 )'); + assert.ok( !d('x'), 'non-digit alphabet'); + assert.ok( !d('1x'), 'digit + alphabet'); + assert.ok( !d('x1'), 'alphabet + digit'); + assert.ok( !d('@'), 'non-digit symbols'); + assert.ok( !d('1-'), 'negative after (1-) not allowed?'); + assert.ok( !d('1+'), 'plus after (1+) not allowed?'); + assert.ok( !d('$2'), 'no money; the currency parser will catch these'); + assert.ok( !d(''), "empty string ('')"); }); /************************************************ @@ -328,12 +326,12 @@ $(function(){ QUnit.test( 'isValueInArray', function(assert) { var v = ts.isValueInArray; assert.expect(6); - ok( v( 0, null ) < 0, 'null' ); - ok( v( 0, [] ) < 0, 'Empty array' ); - ok( v( 1, [[ 1,0 ], [ 0,0 ]] ) === 0, 'Column found (first array)' ); - ok( v( 1, [[ 0,0 ], [ 1,0 ]] ) === 1, 'Column found (second array)' ); - ok( v( 4, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) === 2, 'Column found (third array)' ); - ok( v( 3, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) < 0 , 'Column not found' ); + assert.ok( v( 0, null ) < 0, 'null' ); + assert.ok( v( 0, [] ) < 0, 'Empty array' ); + assert.ok( v( 1, [[ 1,0 ], [ 0,0 ]] ) === 0, 'Column found (first array)' ); + assert.ok( v( 1, [[ 0,0 ], [ 1,0 ]] ) === 1, 'Column found (second array)' ); + assert.ok( v( 4, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) === 2, 'Column found (third array)' ); + assert.ok( v( 3, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) < 0 , 'Column not found' ); }); /************************************************ @@ -363,15 +361,15 @@ $(function(){ }; $table3.trigger('sorton', [[[0,0], [1,0]]]); p( $table3, true ); - ok( findClasses( true, [ 0, 1 ] ), 'Processing 2 columns' ); + assert.ok( findClasses( true, [ 0, 1 ] ), 'Processing 2 columns' ); p( $table3, false ); - ok( findClasses( false, [ -1 ] ), 'No sort' ); + assert.ok( findClasses( false, [ -1 ] ), 'No sort' ); p( $table3, true, c3.$headers.eq(4) ); - ok( findClasses( true, [ -1 ] ), 'Processing specified column not in sortList' ); + assert.ok( findClasses( true, [ -1 ] ), 'Processing specified column not in sortList' ); p( $table3, true, c3.$headers.eq(1) ); - ok( findClasses( true, [ 1 ] ), 'Processing specified column in sortList' ); + assert.ok( findClasses( true, [ 1 ] ), 'Processing specified column in sortList' ); $table3.trigger('sortReset'); - ok( findClasses( false, [ -1 ] ), 'No sort' ); + assert.ok( findClasses( false, [ -1 ] ), 'No sort' ); }); /************************************************