Skip to content

Commit a289830

Browse files
committed
Tests: Lint.
1 parent cb8474a commit a289830

14 files changed

+141
-109
lines changed

grunt.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,31 @@ grunt.initConfig({
345345
browser: true,
346346
jquery: true
347347
}, defaults ),
348+
// TODO: don't create so many globals in tests
348349
globals: {
350+
accordion_state: true,
351+
asyncTest: true,
352+
commonWidgetTests: true,
353+
deepEqual: true,
354+
dlg: true,
355+
domEqual: true,
356+
drag: true,
357+
el: true,
358+
equal: true,
359+
expect: true,
360+
Globalize: true,
361+
menu_click: true,
362+
menu_log: true,
349363
module: true,
350-
test: true,
351364
ok: true,
352-
equal: true,
353-
deepEqual: true,
354-
QUnit: true
365+
QUnit: true,
366+
spinner_simulateKeyDownUp: true,
367+
start: true,
368+
strictEqual: true,
369+
stop: true,
370+
tabs_state: true,
371+
tabs_disabled: true,
372+
test: true
355373
}
356374
}
357375
};

tests/unit/spinner/spinner_core.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test( "mouse click on up button, increases value not greater than max", function
9999
min: 0
100100
}),
101101
button = element.spinner( "widget" ).find( ".ui-spinner-down" );
102-
102+
103103
button.trigger( "mousedown" ).trigger( "mouseup" );
104104
equal( element.val(), 1 );
105105
button.trigger( "mousedown" ).trigger( "mouseup" );
@@ -189,8 +189,8 @@ test( "don't clear invalid value on blur", function() {
189189

190190
test( "precision", function() {
191191
expect( 2 );
192-
var element = $( "#spin" ).val( .05 ).spinner({
193-
step: .0001
192+
var element = $( "#spin" ).val( 0.05 ).spinner({
193+
step: 0.0001
194194
});
195195
element.spinner( "stepUp" );
196196
equal( element.val(), "0.0501", "precision from step" );

tests/unit/spinner/spinner_methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test( "disable", function() {
5454

5555
test( "enable", function() {
5656
expect( 5 );
57-
var element = $( "#spin" ).val( 1 ).spinner({ disabled: true })
57+
var element = $( "#spin" ).val( 1 ).spinner({ disabled: true }),
5858
wrapper = element.spinner( "widget" );
5959

6060
ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" );

tests/unit/spinner/spinner_options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ test( "min, string", function() {
191191
equal( element.spinner( "option", "min" ), -100, "option converted to number" );
192192

193193
element.spinner( "value", -1000 );
194-
equal( element.val(), "($100.00)", "min constrained in value method")
194+
equal( element.val(), "($100.00)", "min constrained in value method" );
195195
});
196196

197197
test( "step, 2", function() {

tests/unit/subsuite.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
(function() {
22

3-
var versions = [ "1.6", "1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.7", "1.7.1", "1.7.2", "git" ];
4-
5-
var additionalTests = {
6-
accordion: [ "accordion_deprecated.html" ],
7-
position: [ "position_deprecated.html" ],
8-
tabs: [ "tabs_deprecated.html" ]
9-
};
3+
var versions = [ "1.6", "1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.7", "1.7.1", "1.7.2", "git" ],
4+
additionalTests = {
5+
accordion: [ "accordion_deprecated.html" ],
6+
position: [ "position_deprecated.html" ],
7+
tabs: [ "tabs_deprecated.html" ]
8+
};
109

1110
window.testAllVersions = function( widget ) {
1211
QUnit.testSuites( $.map(

tests/unit/subsuiteRunner.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ var subsuiteFrame;
44

55
QUnit.extend( QUnit, {
66
testSuites: function( suites ) {
7+
function generateSuite( suite ) {
8+
asyncTest( suite, function() {
9+
QUnit.runSuite( suite );
10+
});
11+
}
12+
713
for ( var i = 0; i < suites.length; i++ ) {
8-
(function( suite ) {
9-
asyncTest( suite, function() {
10-
QUnit.runSuite( suite );
11-
});
12-
}( suites[i] ) );
14+
generateSuite( suites[ i ] );
1315
}
16+
1417
QUnit.done = function() {
1518
subsuiteFrame.style.display = "none";
1619
};
@@ -23,21 +26,24 @@ QUnit.extend( QUnit, {
2326

2427
testDone: function() {
2528
var current = QUnit.id( this.config.current.id ),
26-
children = current.children;
29+
children = current.children,
30+
i = 0,
31+
length = children.length;
2732

2833
// undo the auto-expansion of failed tests
29-
for ( var i = 0; i < children.length; i++ ) {
34+
for ( ; i < length; i++ ) {
3035
if ( children[i].nodeName === "OL" ) {
3136
children[i].style.display = "none";
3237
}
3338
}
3439
},
3540

3641
runSuite: function( suite ) {
37-
var body = document.getElementsByTagName( "body" )[0],
38-
iframe = subsuiteFrame = document.createElement( "iframe" ),
39-
iframeWin;
42+
var iframeWin,
43+
body = document.getElementsByTagName( "body" )[0],
44+
iframe = document.createElement( "iframe" );
4045

46+
subsuiteFrame = iframe;
4147
iframe.className = "qunit-subsuite";
4248
body.appendChild( iframe );
4349

tests/unit/swarminject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
if ( !url || url.indexOf("http") !== 0 ) {
66
return;
77
}
8-
document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
8+
document.write( "<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() + "'></scr" + "ipt>" );
99
})();

tests/unit/tabs/tabs_deprecated.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ test( "tabTemplate + panelTemplate", function() {
8989
// defaults are tested in the add method test
9090
expect( 11 );
9191

92-
var element = $( "#tabs2" ).tabs({
93-
tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
94-
panelTemplate: "<div class='customPanel'></div>"
95-
});
92+
var tab, anchor,
93+
element = $( "#tabs2" ).tabs({
94+
tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
95+
panelTemplate: "<div class='customPanel'></div>"
96+
});
9697
element.one( "tabsadd", function( event, ui ) {
9798
var anchor = $( ui.tab );
9899
equal( ui.index, 5, "ui.index" );
@@ -103,8 +104,8 @@ test( "tabTemplate + panelTemplate", function() {
103104
ok( $( ui.panel ).hasClass( "customPanel" ), "panel custom class" );
104105
});
105106
element.tabs( "add", "#new", "New" );
106-
var tab = element.find( ".ui-tabs-nav li" ).last(),
107-
anchor = tab.find( "a" );
107+
tab = element.find( ".ui-tabs-nav li" ).last();
108+
anchor = tab.find( "a" );
108109
equal( tab.text(), "New", "label" );
109110
ok( tab.hasClass( "customTab" ), "tab custom class" );
110111
equal( anchor.attr( "href" ), "http://example.com/#new", "href" );
@@ -393,7 +394,8 @@ module( "tabs (deprecated): methods" );
393394
test( "add", function() {
394395
expect( 27 );
395396

396-
var element = $( "#tabs1" ).tabs();
397+
var tab, anchor,
398+
element = $( "#tabs1" ).tabs();
397399
tabs_state( element, 1, 0, 0 );
398400

399401
// add without index
@@ -404,8 +406,8 @@ test( "add", function() {
404406
});
405407
element.tabs( "add", "#new", "New" );
406408
tabs_state( element, 1, 0, 0, 0 );
407-
var tab = element.find( ".ui-tabs-nav li" ).last(),
408-
anchor = tab.find( "a" );
409+
tab = element.find( ".ui-tabs-nav li" ).last();
410+
anchor = tab.find( "a" );
409411
equal( tab.text(), "New", "label" );
410412
equal( anchor.attr( "href" ), "#new", "href" );
411413
equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );

tests/unit/tabs/tabs_methods.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ asyncTest( "load", function() {
167167
element.one( "tabsload", function( event, ui ) {
168168
// TODO: remove wrapping in 2.0
169169
var uiTab = $( ui.tab ),
170-
uiPanel = $( ui.panel );
171-
172-
var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
170+
uiPanel = $( ui.panel ),
171+
tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
173172
panelId = tab.attr( "aria-controls" ),
174173
panel = $( "#" + panelId );
175174

@@ -215,9 +214,8 @@ asyncTest( "load", function() {
215214
element.one( "tabsload", function( event, ui ) {
216215
// TODO: remove wrapping in 2.0
217216
var uiTab = $( ui.tab ),
218-
uiPanel = $( ui.panel );
219-
220-
var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
217+
uiPanel = $( ui.panel ),
218+
tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
221219
panelId = tab.attr( "aria-controls" ),
222220
panel = $( "#" + panelId );
223221

tests/unit/testsuite.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ window.commonWidgetTests = function( widget, settings ) {
6363
test( "version", function() {
6464
ok( "version" in $.ui[ widget ].prototype, "version property exists" );
6565
});
66-
}
66+
};
6767

6868
/*
6969
* Experimental assertion for comparing DOM objects.
@@ -72,20 +72,22 @@ window.commonWidgetTests = function( widget, settings ) {
7272
* Then compares the result using deepEqual.
7373
*/
7474
window.domEqual = function( selector, modifier, message ) {
75-
var attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"];
75+
var expected, actual,
76+
attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"];
7677

7778
function extract(value) {
7879
if (!value || !value.length) {
7980
QUnit.push( false, actual, expected, "domEqual failed, can't extract " + selector + ", message was: " + message );
8081
return;
8182
}
82-
var result = {};
83+
var children,
84+
result = {};
8385
result.nodeName = value[0].nodeName;
8486
$.each(attributes, function(index, attr) {
8587
result[attr] = value.prop(attr);
8688
});
8789
result.children = [];
88-
var children = value.children();
90+
children = value.children();
8991
if (children.length) {
9092
children.each(function() {
9193
result.children.push(extract($(this)));
@@ -95,11 +97,11 @@ window.domEqual = function( selector, modifier, message ) {
9597
}
9698
return result;
9799
}
98-
var expected = extract($(selector));
99-
modifier($(selector));
100+
expected = extract( $( selector ) );
101+
modifier( $( selector ) );
100102

101-
var actual = extract($(selector));
103+
actual = extract( $( selector ) );
102104
QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
103-
}
105+
};
104106

105107
}());

tests/unit/tooltip/tooltip_methods.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ test( "destroy", function() {
1616
test( "open/close", function() {
1717
expect( 3 );
1818
$.fx.off = true;
19-
var element = $( "#tooltipped1" ).tooltip();
19+
var tooltip,
20+
element = $( "#tooltipped1" ).tooltip();
2021
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
2122

2223
element.tooltip( "open" );
23-
var tooltip = $( "#" + element.attr( "aria-describedby" ) );
24+
tooltip = $( "#" + element.attr( "aria-describedby" ) );
2425
ok( tooltip.is( ":visible" ) );
2526

2627
element.tooltip( "close" );
@@ -31,11 +32,12 @@ test( "open/close", function() {
3132
test( "enable/disable", function() {
3233
expect( 7 );
3334
$.fx.off = true;
34-
var element = $( "#tooltipped1" ).tooltip();
35+
var tooltip,
36+
element = $( "#tooltipped1" ).tooltip();
3537
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
3638

3739
element.tooltip( "open" );
38-
var tooltip = $( "#" + element.attr( "aria-describedby" ) );
40+
tooltip = $( "#" + element.attr( "aria-describedby" ) );
3941
ok( tooltip.is( ":visible" ) );
4042

4143
element.tooltip( "disable" );

tests/unit/tooltip/tooltip_options.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ asyncTest( "content: sync + async callback", function() {
4545

4646
test( "items", function() {
4747
expect( 2 );
48-
var element = $( "#qunit-fixture" ).tooltip({
49-
items: "#fixture-span"
50-
});
48+
var event,
49+
element = $( "#qunit-fixture" ).tooltip({
50+
items: "#fixture-span"
51+
});
5152

52-
var event = $.Event( "mouseenter" );
53+
event = $.Event( "mouseenter" );
5354
event.target = $( "#fixture-span" )[ 0 ];
5455
element.tooltip( "open", event );
5556
deepEqual( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
@@ -63,7 +64,7 @@ test( "items", function() {
6364
});
6465

6566
test( "tooltipClass", function() {
66-
expect( 1 )
67+
expect( 1 );
6768
var element = $( "#tooltipped1" ).tooltip({
6869
tooltipClass: "custom"
6970
}).tooltip( "open" );

0 commit comments

Comments
 (0)