Skip to content

Commit fc133d5

Browse files
committed
(fix) Tests: Replace resource loader with AMD
Cleanup be3b2b2
1 parent 2077a12 commit fc133d5

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

tests/unit/helper/jquery.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ if( !window.helper ) {
66

77
window.helper.jqueryUrl = function() {
88

9-
var parts = document.location.search.slice( 1 ).split( "&" ),
10-
length = parts.length,
9+
var current, url, version,
1110
i = 0,
12-
current,
13-
version,
14-
url;
11+
length = parts.length,
12+
parts = document.location.search.slice( 1 ).split( "&" );
1513

1614
for ( ; i < length; i++ ) {
1715
current = parts[ i ].split( "=" );

tests/unit/helper/testsuite.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var exports = {};
88
function testWidgetDefaults( widget, defaults ) {
99
var pluginDefaults = $.ui[ widget ].prototype.options;
1010

11-
// ensure that all defaults have the correct value
11+
// Ensure that all defaults have the correct value
1212
test( "defined defaults", function() {
1313
var count = 0;
1414
$.each( defaults, function( key, val ) {
@@ -21,7 +21,7 @@ function testWidgetDefaults( widget, defaults ) {
2121
});
2222
});
2323

24-
// ensure that all defaults were tested
24+
// Ensure that all defaults were tested
2525
test( "tested defaults", function() {
2626
var count = 0;
2727
$.each( pluginDefaults, function( key ) {
@@ -59,14 +59,16 @@ function testBasicUsage( widget ) {
5959
$( defaultElement )[ widget ]().remove();
6060
ok( true, "initialized on disconnected DOMElement - never connected" );
6161

62+
// Ensure manipulating removed elements works (#3664)
6263
$( defaultElement ).appendTo( "body" ).remove()[ widget ]().remove();
6364
ok( true, "initialized on disconnected DOMElement - removed" );
6465
});
6566
}
6667

6768
// Asset revisioning through time and random hashing
6869
function revStamp( value ) {
69-
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random() * 100000, 10);
70+
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" +
71+
parseInt(Math.random() * 100000, 10);
7072
}
7173

7274
/**
@@ -89,8 +91,8 @@ exports.commonWidgetTests = function( widget, settings ) {
8991
/**
9092
* Experimental assertion for comparing DOM objects.
9193
*
92-
* Serializes an element and some properties and attributes and it's children if any, otherwise the text.
93-
* Then compares the result using deepEqual.
94+
* Serializes an element and some properties and attributes and its children if any,
95+
* otherwise the text. Then compares the result using deepEqual().
9496
*/
9597
exports.domEqual = function( selector, modifier, message ) {
9698
var expected, actual,

tests/unit/testsuite.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ window.TestHelpers = {};
99
reset = QUnit.reset;
1010
QUnit.reset = function() {
1111
// Ensure jQuery events and data on the fixture are properly removed
12-
jQuery("#qunit-fixture").empty();
12+
jQuery( "#qunit-fixture" ).empty();
1313
// Let QUnit reset the fixture
1414
reset.apply( this, arguments );
1515
};
@@ -44,7 +44,7 @@ QUnit.config.urlConfig.push({
4444
tooltip: "Which jQuery Core version to test against"
4545
});
4646

47-
TestHelpers.onFocus= function( element, onFocus ) {
47+
TestHelpers.onFocus = function( element, onFocus ) {
4848
var fn = function( event ){
4949
if( !event.originalEvent ) {
5050
return;
@@ -57,6 +57,7 @@ TestHelpers.onFocus= function( element, onFocus ) {
5757
};
5858

5959
TestHelpers.forceScrollableWindow = function( appendTo ) {
60+
6061
// The main testable area is 10000x10000 so to enforce scrolling,
6162
// this DIV must be greater than 10000 to work
6263
return $( "<div>" ).css({
@@ -65,12 +66,10 @@ TestHelpers.forceScrollableWindow = function( appendTo ) {
6566
}).appendTo( appendTo || "#qunit-fixture" );
6667
};
6768

68-
/*
69-
* Taken from https://github.com/jquery/qunit/tree/master/addons/close-enough
70-
*/
69+
// Taken from https://github.com/jquery/qunit/tree/master/addons/close-enough
7170
window.closeEnough = function( actual, expected, maxDifference, message ) {
72-
var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference;
73-
QUnit.push(passes, actual, expected, message);
71+
var passes = ( actual === expected ) || Math.abs( actual - expected ) <= maxDifference;
72+
QUnit.push( passes, actual, expected, message );
7473
};
7574

7675
});

0 commit comments

Comments
 (0)