Skip to content

Commit 266cc84

Browse files
committed
Tests: Lint.
1 parent af1b4d8 commit 266cc84

File tree

6 files changed

+191
-189
lines changed

6 files changed

+191
-189
lines changed

grunt.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ grunt.initConfig({
350350
accordion_equalHeights: true,
351351
accordion_setupTeardown: true,
352352
accordion_state: true,
353+
addMonths: true,
353354
asyncTest: true,
354355
commonWidgetTests: true,
355356
container: true,
@@ -362,9 +363,11 @@ grunt.initConfig({
362363
dragged: true,
363364
el: true,
364365
equal: true,
366+
equalsDate: true,
365367
expect: true,
366368
Globalize: true,
367369
heightAfter: true,
370+
init: true,
368371
isNotOpen: true,
369372
isOpen: true,
370373
menu_click: true,
@@ -376,6 +379,7 @@ grunt.initConfig({
376379
offsetAfter: true,
377380
offsetBefore: true,
378381
ok: true,
382+
PROP_NAME: true,
379383
QUnit: true,
380384
restoreScroll: true,
381385
shouldBeDroppable: true,

tests/unit/datepicker/datepicker_core.js

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -53,52 +53,52 @@ test("widget method", function() {
5353
});
5454

5555
test('baseStructure', function() {
56-
var inp = init('#inp');
57-
inp.focus();
58-
var dp = $('#ui-datepicker-div');
59-
var iframe = ($.browser.msie && parseInt($.browser.version) < 7);
56+
var header, title, table, thead, week, panel, inl, child,
57+
inp = init('#inp').focus(),
58+
dp = $('#ui-datepicker-div'),
59+
iframe = ($.browser.msie && parseInt($.browser.version, 10) < 7);
6060
ok(dp.is(':visible'), 'Structure - datepicker visible');
6161
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
6262
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
6363
equal(dp.children().length, 2 + (iframe ? 1 : 0), 'Structure - child count');
6464

65-
var header = dp.children(':first');
65+
header = dp.children(':first');
6666
ok(header.is('div.ui-datepicker-header'), 'Structure - header division');
6767
equal(header.children().length, 3, 'Structure - header child count');
68-
ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() != '', 'Structure - prev link');
69-
ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() != '', 'Structure - next link');
68+
ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link');
69+
ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link');
7070

71-
var title = header.children(':last');
72-
ok(title.is('div.ui-datepicker-title') && title.html() != '','Structure - title division');
71+
title = header.children(':last');
72+
ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division');
7373
equal(title.children().length, 2, 'Structure - title child count');
74-
ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() != '', 'Structure - month text')
75-
ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() != '', 'Structure - year text')
74+
ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text');
75+
ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text');
7676

77-
var table = dp.children(':eq(1)');
77+
table = dp.children(':eq(1)');
7878
ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table');
7979
ok(table.children(':first').is('thead'), 'Structure - month table thead');
80-
var thead = table.children(':first').children(':first');
80+
thead = table.children(':first').children(':first');
8181
ok(thead.is('tr'), 'Structure - month table title row');
8282
equal(thead.find('th').length, 7, 'Structure - month table title cells');
8383
ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body');
8484
ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count');
85-
var week = table.children(':eq(1)').children(':first');
85+
week = table.children(':eq(1)').children(':first');
8686
ok(week.is('tr'), 'Structure - month table week row');
8787
equal(week.children().length, 7, 'Structure - week child count');
8888
ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell');
8989
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
90-
ok(dp.children('iframe').length == (iframe ? 1 : 0), 'Structure - iframe');
90+
ok(dp.children('iframe').length === (iframe ? 1 : 0), 'Structure - iframe');
9191
inp.datepicker('hide').datepicker('destroy');
9292

9393
// Editable month/year and button panel
9494
inp = init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
9595
inp.focus();
9696

97-
var title = dp.find('div.ui-datepicker-title');
97+
title = dp.find('div.ui-datepicker-title');
9898
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector');
9999
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector');
100100

101-
var panel = dp.children(':last');
101+
panel = dp.children(':last');
102102
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division');
103103
equal(panel.children().length, 2, 'Structure - button panel child count');
104104
ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button');
@@ -110,7 +110,7 @@ test('baseStructure', function() {
110110
inp.focus();
111111
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
112112
equal(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure multi [2] - child count');
113-
var child = dp.children(':first');
113+
child = dp.children(':first');
114114
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division');
115115
child = dp.children(':eq(1)');
116116
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division');
@@ -146,16 +146,16 @@ test('baseStructure', function() {
146146
inp.datepicker('hide').datepicker('destroy');
147147

148148
// Inline
149-
var inl = init('#inl');
149+
inl = init('#inl');
150150
dp = inl.children();
151151
ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');
152152
ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');
153153
ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');
154154
equal(dp.children().length, 2, 'Structure inline - child count');
155-
var header = dp.children(':first');
155+
header = dp.children(':first');
156156
ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division');
157157
equal(header.children().length, 3, 'Structure inline - header child count');
158-
var table = dp.children(':eq(1)');
158+
table = dp.children(':eq(1)');
159159
ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table');
160160
ok(table.children(':first').is('thead'), 'Structure inline - month table thead');
161161
ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body');
@@ -176,19 +176,20 @@ test('baseStructure', function() {
176176
});
177177

178178
test('customStructure', function() {
179-
var dp = $('#ui-datepicker-div');
180-
// Check right-to-left localisation
181-
var inp = init('#inp', $.datepicker.regional['he']);
179+
var iframe, header, panel, title, thead,
180+
dp = $('#ui-datepicker-div'),
181+
// Check right-to-left localisation
182+
inp = init('#inp', $.datepicker.regional.he);
182183
inp.data('showButtonPanel.datepicker',true);
183184
inp.focus();
184-
var iframe = ($.browser.msie && parseInt($.browser.version) < 7);
185+
iframe = ($.browser.msie && parseInt($.browser.version, 10) < 7);
185186
ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left');
186-
var header = dp.children(':first');
187+
header = dp.children(':first');
187188
ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division');
188189
equal(header.children().length, 3, 'Structure RTL - header child count');
189190
ok(header.children(':first').is('a.ui-datepicker-next'), 'Structure RTL - prev link');
190191
ok(header.children(':eq(1)').is('a.ui-datepicker-prev'), 'Structure RTL - next link');
191-
var panel = dp.children(':last');
192+
panel = dp.children(':last');
192193
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure RTL - button division');
193194
equal(panel.children().length, 2, 'Structure RTL - button panel child count');
194195
ok(panel.children(':first').is('button.ui-datepicker-close'), 'Structure RTL - close button');
@@ -198,7 +199,7 @@ test('customStructure', function() {
198199
// Hide prev/next
199200
inp = init('#inp', {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});
200201
inp.val('02/10/2008').focus();
201-
var header = dp.children(':first');
202+
header = dp.children(':first');
202203
ok(header.is('div.ui-datepicker-header'), 'Structure hide prev/next - header division');
203204
equal(header.children().length, 1, 'Structure hide prev/next - links child count');
204205
ok(header.children(':first').is('div.ui-datepicker-title'), 'Structure hide prev/next - title division');
@@ -207,7 +208,7 @@ test('customStructure', function() {
207208
// Changeable Month with read-only year
208209
inp = init('#inp', {changeMonth: true});
209210
inp.focus();
210-
var title = dp.children(':first').children(':last');
211+
title = dp.children(':first').children(':last');
211212
equal(title.children().length, 2, 'Structure changeable month - title child count');
212213
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure changeable month - month selector');
213214
ok(title.children(':last').is('span.ui-datepicker-year'), 'Structure changeable month - read-only year');
@@ -216,7 +217,7 @@ test('customStructure', function() {
216217
// Changeable year with read-only month
217218
inp = init('#inp', {changeYear: true});
218219
inp.focus();
219-
var title = dp.children(':first').children(':last');
220+
title = dp.children(':first').children(':last');
220221
equal(title.children().length, 2, 'Structure changeable year - title child count');
221222
ok(title.children(':first').is('span.ui-datepicker-month'), 'Structure changeable year - read-only month');
222223
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure changeable year - year selector');
@@ -225,15 +226,15 @@ test('customStructure', function() {
225226
// Read-only first day of week
226227
inp = init('#inp', {changeFirstDay: false});
227228
inp.focus();
228-
var thead = dp.find('.ui-datepicker-calendar thead tr');
229+
thead = dp.find('.ui-datepicker-calendar thead tr');
229230
equal(thead.children().length, 7, 'Structure read-only first day - thead child count');
230231
equal(thead.find('a').length, 0, 'Structure read-only first day - thead links count');
231232
inp.datepicker('hide').datepicker('destroy');
232233
});
233234

234235
test('keystrokes', function() {
235-
var inp = init('#inp');
236-
var date = new Date();
236+
var inp = init('#inp'),
237+
date = new Date();
237238
inp.val('').datepicker('show').
238239
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
239240
equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter');
@@ -366,9 +367,10 @@ test('keystrokes', function() {
366367
});
367368

368369
test('mouse', function() {
369-
var inp = init('#inp');
370-
var dp = $('#ui-datepicker-div');
371-
var date = new Date();
370+
var inl,
371+
inp = init('#inp'),
372+
dp = $('#ui-datepicker-div'),
373+
date = new Date();
372374
inp.val('').datepicker('show');
373375
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
374376
date.setDate(10);
@@ -419,9 +421,9 @@ test('mouse', function() {
419421
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18),
420422
'Mouse click - next + min/max');
421423
// Inline
422-
var inl = init('#inl');
423-
var dp = $('.ui-datepicker-inline', inl);
424-
var date = new Date();
424+
inl = init('#inl');
425+
dp = $('.ui-datepicker-inline', inl);
426+
date = new Date();
425427
inl.datepicker('setDate', date);
426428
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
427429
date.setDate(10);

tests/unit/datepicker/datepicker_events.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
module("datepicker: events");
77

8-
var selectedThis = null;
9-
var selectedDate = null;
10-
var selectedInst = null;
8+
var selectedThis = null,
9+
selectedDate = null,
10+
selectedInst = null;
1111

1212
function callback(date, inst) {
1313
selectedThis = this;
@@ -22,8 +22,9 @@ function callback2(year, month, inst) {
2222
}
2323

2424
test('events', function() {
25-
var inp = init('#inp', {onSelect: callback});
26-
var date = new Date();
25+
var dateStr, newMonthYear, inp2,
26+
inp = init('#inp', {onSelect: callback}),
27+
date = new Date();
2728
// onSelect
2829
inp.val('').datepicker('show').
2930
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
@@ -41,15 +42,15 @@ test('events', function() {
4142
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
4243
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
4344
'Callback selected date - esc');
44-
var dateStr = '02/04/2008';
45+
dateStr = '02/04/2008';
4546
inp.val(dateStr).datepicker('show').
4647
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
4748
equal(dateStr, selectedDate,
4849
'onSelect is called after enter keydown');
4950
// onChangeMonthYear
5051
inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}).
5152
val('').datepicker('show');
52-
var newMonthYear = function(date) {
53+
newMonthYear = function(date) {
5354
return date.getFullYear() + '/' + (date.getMonth() + 1);
5455
};
5556
date = new Date();
@@ -118,7 +119,7 @@ test('events', function() {
118119
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
119120
equal(selectedDate, '', 'Callback close date - ctrl+end');
120121

121-
var inp2 = init('#inp2');
122+
inp2 = init('#inp2');
122123
inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
123124
inp.datepicker('show');
124125
equal(selectedThis, inp2[0], 'Callback close this');

tests/unit/datepicker/datepicker_methods.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
module("datepicker: methods");
77

88
test('destroy', function() {
9-
var inp = init('#inp');
9+
var inl,
10+
inp = init('#inp');
1011
ok(inp.is('.hasDatepicker'), 'Default - marker class set');
1112
ok($.data(inp[0], PROP_NAME), 'Default - instance present');
1213
ok(inp.next().is('#alt'), 'Default - button absent');
@@ -19,7 +20,7 @@ test('destroy', function() {
1920
inp= init('#inp', {showOn: 'both'});
2021
ok(inp.is('.hasDatepicker'), 'Button - marker class set');
2122
ok($.data(inp[0], PROP_NAME), 'Button - instance present');
22-
ok(inp.next().text() == '...', 'Button - button added');
23+
ok(inp.next().text() === '...', 'Button - button added');
2324
inp.datepicker('destroy');
2425
inp = $('#inp');
2526
ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared');
@@ -29,7 +30,7 @@ test('destroy', function() {
2930
inp = init('#inp', {appendText: 'Testing'});
3031
ok(inp.is('.hasDatepicker'), 'Append - marker class set');
3132
ok($.data(inp[0], PROP_NAME), 'Append - instance present');
32-
ok(inp.next().text() == 'Testing', 'Append - append text added');
33+
ok(inp.next().text() === 'Testing', 'Append - append text added');
3334
inp.datepicker('destroy');
3435
inp = $('#inp');
3536
ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared');
@@ -40,29 +41,30 @@ test('destroy', function() {
4041
buttonImage: 'img/calendar.gif', appendText: 'Testing'});
4142
ok(inp.is('.hasDatepicker'), 'Both - marker class set');
4243
ok($.data(inp[0], PROP_NAME), 'Both - instance present');
43-
ok(inp.next()[0].nodeName.toLowerCase() == 'img', 'Both - button added');
44-
ok(inp.next().next().text() == 'Testing', 'Both - append text added');
44+
ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added');
45+
ok(inp.next().next().text() === 'Testing', 'Both - append text added');
4546
inp.datepicker('destroy');
4647
inp = $('#inp');
4748
ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared');
4849
ok(!$.data(inp[0], PROP_NAME), 'Both - instance absent');
4950
ok(inp.next().is('#alt'), 'Both - button and append text absent');
5051
// Inline
51-
var inl = init('#inl');
52+
inl = init('#inl');
5253
ok(inl.is('.hasDatepicker'), 'Inline - marker class set');
53-
ok(inl.html() != '', 'Inline - datepicker present');
54+
ok(inl.html() !== '', 'Inline - datepicker present');
5455
ok($.data(inl[0], PROP_NAME), 'Inline - instance present');
55-
ok(inl.next().length == 0 || inl.next().is('p'), 'Inline - button absent');
56+
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
5657
inl.datepicker('destroy');
5758
inl = $('#inl');
5859
ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared');
59-
ok(inl.html() == '', 'Inline - datepicker absent');
60+
ok(inl.html() === '', 'Inline - datepicker absent');
6061
ok(!$.data(inl[0], PROP_NAME), 'Inline - instance absent');
61-
ok(inl.next().length == 0 || inl.next().is('p'), 'Inline - button absent');
62+
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
6263
});
6364

6465
test('enableDisable', function() {
65-
var inp = init('#inp');
66+
var inl, dp,
67+
inp = init('#inp');
6668
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');
6769
ok(!inp[0].disabled, 'Enable/disable - field initially enabled');
6870
inp.datepicker('disable');
@@ -91,19 +93,19 @@ test('enableDisable', function() {
9193
buttonImage: 'img/calendar.gif'});
9294
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled');
9395
ok(!inp[0].disabled, 'Enable/disable image - field initially enabled');
94-
ok(inp.next('img').css('opacity') == 1, 'Enable/disable image - image initially enabled');
96+
ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image initially enabled');
9597
inp.datepicker('disable');
9698
ok(inp.datepicker('isDisabled'), 'Enable/disable image - now marked as disabled');
9799
ok(inp[0].disabled, 'Enable/disable image - field now disabled');
98-
ok(inp.next('img').css('opacity') != 1, 'Enable/disable image - image now disabled');
100+
ok(parseFloat(inp.next('img').css('opacity')) !== 1, 'Enable/disable image - image now disabled');
99101
inp.datepicker('enable');
100102
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - now marked as enabled');
101103
ok(!inp[0].disabled, 'Enable/disable image - field now enabled');
102-
ok(inp.next('img').css('opacity') == 1, 'Enable/disable image - image now enabled');
104+
ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image now enabled');
103105
inp.datepicker('destroy');
104106
// Inline
105-
var inl = init('#inl', {changeYear: true});
106-
var dp = $('.ui-datepicker-inline', inl);
107+
inl = init('#inl', {changeYear: true});
108+
dp = $('.ui-datepicker-inline', inl);
107109
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled');
108110
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially');
109111
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled initially');

0 commit comments

Comments
 (0)