diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-10-23 09:36:42 -0500 |
---|---|---|
committer | Corey Frang <gnarf@gnarf.net> | 2012-10-23 09:37:46 -0500 |
commit | e1230997aa14dae6f35326c8ba20bfe2428507c2 (patch) | |
tree | f00984f5fbbf12f175c0994c497513a2d8e8ee26 /tests/unit/datepicker | |
parent | 7af1ec727bcca8367e804cea77b9dd238b1c0d69 (diff) | |
download | jquery-ui-e1230997aa14dae6f35326c8ba20bfe2428507c2.tar.gz jquery-ui-e1230997aa14dae6f35326c8ba20bfe2428507c2.zip |
Build: Enable "unused" option in jshint - Remove unused variables from codebase. - Closes gh-788
Squashed commit of the following:
commit 7f19f92c646f180bc067bb24123175251a64a9d6
Author: Mike Sherov <mike.sherov@gmail.com>
Date: Tue Oct 23 10:34:28 2012 -0400
put back in fake args for signatures that we want to keep
commit 257505a9e69da0c53e3a989dab87a13112045a29
Author: Mike Sherov <mike.sherov@gmail.com>
Date: Tue Oct 23 08:10:20 2012 -0400
changes per @scott_gonzalez
commit 12725480cb58e70865e5aa6e735009b6b035c8f3
Author: Mike Sherov <mike.sherov@gmail.com>
Date: Mon Oct 22 22:54:05 2012 -0400
clean up unused vars in ui directory
commit 563595e7aee5d4a5c096b2d1de655abdf920aacd
Author: Mike Sherov <mike.sherov@gmail.com>
Date: Mon Oct 22 22:37:42 2012 -0400
clean up unused vars in grunt and tests
Diffstat (limited to 'tests/unit/datepicker')
-rw-r--r-- | tests/unit/datepicker/datepicker_core.js | 18 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_defaults.js | 4 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_events.js | 6 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_methods.js | 20 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_options.js | 24 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_tickets.js | 2 |
6 files changed, 27 insertions, 47 deletions
diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index e17b239e5..4abdfd106 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -12,31 +12,19 @@ function equalsDate(d1, d2, message) { equal(d1.toString(), d2.toString(), message); } -function equalsDateArray(a1, a2, message) { - if (!a1 || !a2) { - ok(false, message + ' - missing dates'); - return; - } - a1[0] = (a1[0] ? new Date(a1[0].getFullYear(), a1[0].getMonth(), a1[0].getDate()) : ''); - a1[1] = (a1[1] ? new Date(a1[1].getFullYear(), a1[1].getMonth(), a1[1].getDate()) : ''); - a2[0] = (a2[0] ? new Date(a2[0].getFullYear(), a2[0].getMonth(), a2[0].getDate()) : ''); - a2[1] = (a2[1] ? new Date(a2[1].getFullYear(), a2[1].getMonth(), a2[1].getDate()) : ''); - deepEqual(a1, a2, message); -} - -function addMonths(date, offset) { +TestHelpers.addMonths = function(date, offset) { var maxDay = 32 - new Date(date.getFullYear(), date.getMonth() + offset, 32).getDate(); date.setDate(Math.min(date.getDate(), maxDay)); date.setMonth(date.getMonth() + offset); return date; -} +}; function init(id, options) { $.datepicker.setDefaults($.datepicker.regional['']); return $(id).datepicker($.extend({showAnim: ''}, options || {})); } -var PROP_NAME = 'datepicker'; +TestHelpers.PROP_NAME = 'datepicker'; (function($) { diff --git a/tests/unit/datepicker/datepicker_defaults.js b/tests/unit/datepicker/datepicker_defaults.js index 28e150791..1e7d90852 100644 --- a/tests/unit/datepicker/datepicker_defaults.js +++ b/tests/unit/datepicker/datepicker_defaults.js @@ -2,8 +2,10 @@ * datepicker_defaults.js */ +/* var datepicker_defaults = { disabled: false }; -//TestHelpers.commonWidgetTests('datepicker', { defaults: datepicker_defaults }); +TestHelpers.commonWidgetTests('datepicker', { defaults: datepicker_defaults }); +*/ diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js index e35be62ce..b71067472 100644 --- a/tests/unit/datepicker/datepicker_events.js +++ b/tests/unit/datepicker/datepicker_events.js @@ -30,7 +30,7 @@ test('events', function() { inp.val('').datepicker('show'). simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); equal(selectedThis, inp[0], 'Callback selected this'); - equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback selected inst'); + equal(selectedInst, $.data(inp[0], TestHelpers.PROP_NAME), 'Callback selected inst'); equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), 'Callback selected date'); inp.val('').datepicker('show'). @@ -59,7 +59,7 @@ test('events', function() { inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}); date.setMonth(date.getMonth() - 1); equal(selectedThis, inp[0], 'Callback change month/year this'); - equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback change month/year inst'); + equal(selectedInst, $.data(inp[0], TestHelpers.PROP_NAME), 'Callback change month/year inst'); equal(selectedDate, newMonthYear(date), 'Callback change month/year date - pgup'); inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}); @@ -107,7 +107,7 @@ test('events', function() { val('').datepicker('show'). simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); equal(selectedThis, inp[0], 'Callback close this'); - equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback close inst'); + equal(selectedInst, $.data(inp[0], TestHelpers.PROP_NAME), 'Callback close inst'); equal(selectedDate, '', 'Callback close date - esc'); inp.val('').datepicker('show'). simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); diff --git a/tests/unit/datepicker/datepicker_methods.js b/tests/unit/datepicker/datepicker_methods.js index e7aa7602e..5e692d1a0 100644 --- a/tests/unit/datepicker/datepicker_methods.js +++ b/tests/unit/datepicker/datepicker_methods.js @@ -10,56 +10,56 @@ test('destroy', function() { var inl, inp = init('#inp'); ok(inp.is('.hasDatepicker'), 'Default - marker class set'); - ok($.data(inp[0], PROP_NAME), 'Default - instance present'); + ok($.data(inp[0], TestHelpers.PROP_NAME), 'Default - instance present'); ok(inp.next().is('#alt'), 'Default - button absent'); inp.datepicker('destroy'); inp = $('#inp'); ok(!inp.is('.hasDatepicker'), 'Default - marker class cleared'); - ok(!$.data(inp[0], PROP_NAME), 'Default - instance absent'); + ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Default - instance absent'); ok(inp.next().is('#alt'), 'Default - button absent'); // With button inp= init('#inp', {showOn: 'both'}); ok(inp.is('.hasDatepicker'), 'Button - marker class set'); - ok($.data(inp[0], PROP_NAME), 'Button - instance present'); + ok($.data(inp[0], TestHelpers.PROP_NAME), 'Button - instance present'); ok(inp.next().text() === '...', 'Button - button added'); inp.datepicker('destroy'); inp = $('#inp'); ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared'); - ok(!$.data(inp[0], PROP_NAME), 'Button - instance absent'); + ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Button - instance absent'); ok(inp.next().is('#alt'), 'Button - button removed'); // With append text inp = init('#inp', {appendText: 'Testing'}); ok(inp.is('.hasDatepicker'), 'Append - marker class set'); - ok($.data(inp[0], PROP_NAME), 'Append - instance present'); + ok($.data(inp[0], TestHelpers.PROP_NAME), 'Append - instance present'); ok(inp.next().text() === 'Testing', 'Append - append text added'); inp.datepicker('destroy'); inp = $('#inp'); ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared'); - ok(!$.data(inp[0], PROP_NAME), 'Append - instance absent'); + ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Append - instance absent'); ok(inp.next().is('#alt'), 'Append - append text removed'); // With both inp= init('#inp', {showOn: 'both', buttonImageOnly: true, buttonImage: 'img/calendar.gif', appendText: 'Testing'}); ok(inp.is('.hasDatepicker'), 'Both - marker class set'); - ok($.data(inp[0], PROP_NAME), 'Both - instance present'); + ok($.data(inp[0], TestHelpers.PROP_NAME), 'Both - instance present'); ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added'); ok(inp.next().next().text() === 'Testing', 'Both - append text added'); inp.datepicker('destroy'); inp = $('#inp'); ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared'); - ok(!$.data(inp[0], PROP_NAME), 'Both - instance absent'); + ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Both - instance absent'); ok(inp.next().is('#alt'), 'Both - button and append text absent'); // Inline inl = init('#inl'); ok(inl.is('.hasDatepicker'), 'Inline - marker class set'); ok(inl.html() !== '', 'Inline - datepicker present'); - ok($.data(inl[0], PROP_NAME), 'Inline - instance present'); + ok($.data(inl[0], TestHelpers.PROP_NAME), 'Inline - instance present'); ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent'); inl.datepicker('destroy'); inl = $('#inl'); ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared'); ok(inl.html() === '', 'Inline - datepicker absent'); - ok(!$.data(inl[0], PROP_NAME), 'Inline - instance absent'); + ok(!$.data(inl[0], TestHelpers.PROP_NAME), 'Inline - instance absent'); ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent'); }); diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index a01b9c7e0..7d3217364 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -8,7 +8,7 @@ module("datepicker: options"); test('setDefaults', function() { expect( 3 ); - var inp = init('#inp'); + init('#inp'); equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn'); $.datepicker.setDefaults({showOn: 'button'}); equal($.datepicker._defaults.showOn, 'button', 'Change default showOn'); @@ -19,7 +19,7 @@ test('setDefaults', function() { test('option', function() { expect( 17 ); var inp = init('#inp'), - inst = $.data(inp[0], PROP_NAME); + inst = $.data(inp[0], TestHelpers.PROP_NAME); // Set option equal(inst.settings.showOn, null, 'Initial setting showOn'); equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); @@ -51,7 +51,7 @@ test('option', function() { test('change', function() { expect( 12 ); var inp = init('#inp'), - inst = $.data(inp[0], PROP_NAME); + inst = $.data(inp[0], TestHelpers.PROP_NAME); equal(inst.settings.showOn, null, 'Initial setting showOn'); equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn'); @@ -215,12 +215,12 @@ test('defaultDate', function() { inp.datepicker('option', {defaultDate: ' -1 m '}). datepicker('hide').val('').datepicker('show'). simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - date = addMonths(new Date(), -1); + date = TestHelpers.addMonths(new Date(), -1); equalsDate(inp.datepicker('getDate'), date, 'Default date -1 m'); inp.datepicker('option', {defaultDate: '+2M'}). datepicker('hide').val('').datepicker('show'). simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - date = addMonths(new Date(), 2); + date = TestHelpers.addMonths(new Date(), 2); equalsDate(inp.datepicker('getDate'), date, 'Default date +2M'); inp.datepicker('option', {defaultDate: '-2y'}). datepicker('hide').val('').datepicker('show'). @@ -236,7 +236,7 @@ test('defaultDate', function() { inp.datepicker('option', {defaultDate: '+1M +10d'}). datepicker('hide').val('').datepicker('show'). simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - date = addMonths(new Date(), 1); + date = TestHelpers.addMonths(new Date(), 1); date.setDate(date.getDate() + 10); equalsDate(inp.datepicker('getDate'), date, 'Default date +1M +10d'); // String date values @@ -380,7 +380,7 @@ test('minMax', function() { simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); equalsDate(inp.datepicker('getDate'), date, 'Min/max - -1w, +1 M +10 D - ctrl+pgup'); - date = addMonths(new Date(), 1); + date = TestHelpers.addMonths(new Date(), 1); date.setDate(date.getDate() + 10); inp.val('').datepicker('show'); inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). @@ -665,16 +665,6 @@ function beforeDay(date) { (date.getDate() % 3 === 0 ? 'Divisble by 3' : '')]; } -function calcWeek(date) { - var doy = date.getDate() + 6, - m = date.getMonth() - 1; - for (; m >= 0; m--) { - doy += $.datepicker._getDaysInMonth(date.getFullYear(), m); - } - // Simple count from 01/01 starting at week 1 - return Math.floor(doy / 7); -} - test('callbacks', function() { expect( 13 ); // Before show diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js index 57b25c3ff..ff5dfde63 100644 --- a/tests/unit/datepicker/datepicker_tickets.js +++ b/tests/unit/datepicker/datepicker_tickets.js @@ -8,7 +8,7 @@ module("datepicker: tickets"); // http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1 test('beforeShowDay-getDate', function() { expect( 3 ); - var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }}), + var inp = init('#inp', {beforeShowDay: function() { inp.datepicker('getDate'); return [true, '']; }}), dp = $('#ui-datepicker-div'); inp.val('01/01/2010').datepicker('show'); // contains non-breaking space |