Skip to content

Tests: Replace resource loader with AMD #1335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bb47aad
Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
78801c6
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
df62114
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
3afb4d0
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
5ca958a
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
2834651
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
8ac5a49
Revert "(fix) Tests: Replace resource loader with AMD"
rxaviers Sep 3, 2014
b2d649f
(fix) Tests: Replace resource loader with AMD
rxaviers Sep 3, 2014
cf94731
(fix) Tests: Replace resource loader with AMD
rxaviers Sep 3, 2014
21bbc2e
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
337b775
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
cdfc27e
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
9c3d95c
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
bc593d3
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
7655302
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
64b786f
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
b810fc3
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
757164d
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
8281580
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
f44cb7c
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(fix) Tests: Replace resource loader with AMD
Cleanup be3b2b2
  • Loading branch information
rxaviers committed Nov 14, 2014
commit b2d649f2498c805a37f5e3afab287cf717c36110
8 changes: 3 additions & 5 deletions tests/unit/helper/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ if( !window.helper ) {

window.helper.jqueryUrl = function() {

var parts = document.location.search.slice( 1 ).split( "&" ),
length = parts.length,
var current, url, version,
i = 0,
current,
version,
url;
length = parts.length,
parts = document.location.search.slice( 1 ).split( "&" );

for ( ; i < length; i++ ) {
current = parts[ i ].split( "=" );
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/helper/testsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var exports = {};
function testWidgetDefaults( widget, defaults ) {
var pluginDefaults = $.ui[ widget ].prototype.options;

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

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

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

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

/**
Expand All @@ -89,8 +91,8 @@ exports.commonWidgetTests = function( widget, settings ) {
/**
* Experimental assertion for comparing DOM objects.
*
* Serializes an element and some properties and attributes and it's children if any, otherwise the text.
* Then compares the result using deepEqual.
* Serializes an element and some properties and attributes and its children if any,
* otherwise the text. Then compares the result using deepEqual().
*/
exports.domEqual = function( selector, modifier, message ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if anything, these should become actual QUnit assertions rather than be exposed from the testsuite API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this is equivalent to window.closeEnough in terms of what it's accomplishing: providing a global assertion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's get that part fixed in master so that the diff in here is limited to the AMD changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

var expected, actual,
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/testsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.TestHelpers = {};
reset = QUnit.reset;
QUnit.reset = function() {
// Ensure jQuery events and data on the fixture are properly removed
jQuery("#qunit-fixture").empty();
jQuery( "#qunit-fixture" ).empty();
// Let QUnit reset the fixture
reset.apply( this, arguments );
};
Expand Down Expand Up @@ -44,7 +44,7 @@ QUnit.config.urlConfig.push({
tooltip: "Which jQuery Core version to test against"
});

TestHelpers.onFocus= function( element, onFocus ) {
TestHelpers.onFocus = function( element, onFocus ) {
var fn = function( event ){
if( !event.originalEvent ) {
return;
Expand All @@ -57,6 +57,7 @@ TestHelpers.onFocus= function( element, onFocus ) {
};

TestHelpers.forceScrollableWindow = function( appendTo ) {

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

/*
* Taken from https://github.com/jquery/qunit/tree/master/addons/close-enough
*/
// Taken from https://github.com/jquery/qunit/tree/master/addons/close-enough
window.closeEnough = function( actual, expected, maxDifference, message ) {
var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference;
QUnit.push(passes, actual, expected, message);
var passes = ( actual === expected ) || Math.abs( actual - expected ) <= maxDifference;
QUnit.push( passes, actual, expected, message );
};

});