Skip to content

Convert test infrastructure to AMD #1528

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 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
741661f
Tests: Change test infrastructure to use AMD and reduce boilerplate
scottgonzalez Apr 3, 2015
3a3d46e
Tests: Convert closeEnough() to a proper QUnit assertion
scottgonzalez Mar 31, 2015
1ce65bd
Accordion: Convert tests to new infrastructure
scottgonzalez Apr 3, 2015
5419cc4
Autocomplete: Convert tests to new infrastructure
scottgonzalez Apr 3, 2015
b7e2c58
Button: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
39403e6
Core: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
a408877
Draggable: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
f5eae5b
Effects: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
797118d
Menu: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
f429be0
Position: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
0df224f
Progressbar: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
e0399fb
Resizable: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
64cebb2
Selectable: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
eec2e91
Selectmenu: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
c51d81e
Slider: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
a3222d1
Sortable: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
69ed8ab
Tabs: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
e39eee2
Widget: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
09813d0
Spinner: Convert tests to new infrastructure
scottgonzalez Apr 6, 2015
2f0ebad
Datepicker: Convert tests to new infrastructure
scottgonzalez Apr 7, 2015
652ee4c
Tests: Support `$.uiBackCompat = false` via `data-no-back-compat`
scottgonzalez Apr 7, 2015
42c93e2
Dialog: Convert tests to new infrastructure
scottgonzalez Apr 7, 2015
55c8af7
Tooltip: Convert tests to new infrastructure
scottgonzalez Apr 7, 2015
129d565
Droppable: Convert tests to new infrastructure
scottgonzalez Apr 7, 2015
3ec2b22
Tests: Remove old test infrastructure
scottgonzalez Apr 7, 2015
ca04a6f
Tests: Widget test helpers extend the main helper
scottgonzalez Apr 7, 2015
3065df6
Tests: Rename files
scottgonzalez Apr 7, 2015
23a05f8
Tests: Use the qunit-assert-close module
scottgonzalez Apr 8, 2015
426408c
Build: Upgrade to qunit-composite 1.1.0
scottgonzalez Apr 9, 2015
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
6 changes: 6 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ grunt.initConfig({
return !( /(all|index|test)\.html$/ ).test( file );
}),
options: {
inject: false,
page: {
viewportSize: { width: 700, height: 500 }
}
Expand Down Expand Up @@ -280,10 +281,15 @@ grunt.initConfig({
"qunit-assert-classes/qunit-assert-classes.js": "qunit-assert-classes/qunit-assert-classes.js",
"qunit-assert-classes/LICENSE.txt": "qunit-assert-classes/LICENSE",

"qunit-assert-close/qunit-assert-close.js": "qunit-assert-close/qunit-assert-close.js",
"qunit-assert-close/MIT-LICENSE.txt": "qunit-assert-close/MIT-LICENSE.txt",

"qunit-composite/qunit-composite.js": "qunit-composite/qunit-composite.js",
"qunit-composite/qunit-composite.css": "qunit-composite/qunit-composite.css",
"qunit-composite/LICENSE.txt": "qunit-composite/LICENSE.txt",

"requirejs/require.js": "requirejs/require.js",

"jquery-mousewheel/jquery.mousewheel.js": "jquery-mousewheel/jquery.mousewheel.js",
"jquery-mousewheel/LICENSE.txt": "jquery-mousewheel/LICENSE.txt",

Expand Down
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"jshint": "2.4.4",
"qunit": "1.18.0",
"qunit-assert-classes": "0.1.5",
"qunit-composite": "JamesMGreene/qunit-composite#v1.0.4",
"qunit-assert-close": "JamesMGreene/qunit-assert-close#v1.1.1",
"qunit-composite": "JamesMGreene/qunit-composite#v1.1.0",
"requirejs": "2.1.14",

"jquery-1.7.0": "jquery#1.7.0",
"jquery-1.7.1": "jquery#1.7.1",
Expand Down
21 changes: 21 additions & 0 deletions external/qunit-assert-close/MIT-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright jQuery Foundation and other contributors
http://jquery.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
106 changes: 106 additions & 0 deletions external/qunit-assert-close/qunit-assert-close.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
* based on a specified maximum allowable difference.
*
* @example assert.close(3.141, Math.PI, 0.001);
*
* @param Number actual
* @param Number expected
* @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)
* @param String message (optional)
*/
function close(actual, expected, maxDifference, message) {
var actualDiff = (actual === expected) ? 0 : Math.abs(actual - expected),
result = actualDiff <= maxDifference;
message = message || (actual + " should be within " + maxDifference + " (inclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff));
QUnit.push(result, actual, expected, message);
}


/**
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
* based on a specified maximum allowable difference percentage.
*
* @example assert.close.percent(155, 150, 3.4); // Difference is ~3.33%
*
* @param Number actual
* @param Number expected
* @param Number maxPercentDifference (the maximum inclusive difference percentage allowed between the actual and expected numbers)
* @param String message (optional)
*/
close.percent = function closePercent(actual, expected, maxPercentDifference, message) {
var actualDiff, result;
if (actual === expected) {
actualDiff = 0;
result = actualDiff <= maxPercentDifference;
}
else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
actualDiff = Math.abs(100 * (actual - expected) / expected);
result = actualDiff <= maxPercentDifference;
}
else {
// Dividing by zero (0)! Should return `false` unless the max percentage was `Infinity`
actualDiff = Infinity;
result = maxPercentDifference === Infinity;
}
message = message || (actual + " should be within " + maxPercentDifference + "% (inclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff + "%"));

QUnit.push(result, actual, expected, message);
};


/**
* Checks that the first two arguments are numbers with differences greater than the specified
* minimum difference.
*
* @example assert.notClose(3.1, Math.PI, 0.001);
*
* @param Number actual
* @param Number expected
* @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)
* @param String message (optional)
*/
function notClose(actual, expected, minDifference, message) {
var actualDiff = Math.abs(actual - expected),
result = actualDiff > minDifference;
message = message || (actual + " should not be within " + minDifference + " (exclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff));
QUnit.push(result, actual, expected, message);
}


/**
* Checks that the first two arguments are numbers with differences greater than the specified
* minimum difference percentage.
*
* @example assert.notClose.percent(156, 150, 3.5); // Difference is 4.0%
*
* @param Number actual
* @param Number expected
* @param Number minPercentDifference (the minimum exclusive difference percentage allowed between the actual and expected numbers)
* @param String message (optional)
*/
notClose.percent = function notClosePercent(actual, expected, minPercentDifference, message) {
var actualDiff, result;
if (actual === expected) {
actualDiff = 0;
result = actualDiff > minPercentDifference;
}
else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
actualDiff = Math.abs(100 * (actual - expected) / expected);
result = actualDiff > minPercentDifference;
}
else {
// Dividing by zero (0)! Should only return `true` if the min percentage was `Infinity`
actualDiff = Infinity;
result = minPercentDifference !== Infinity;
}
message = message || (actual + " should not be within " + minPercentDifference + "% (exclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff + "%"));

QUnit.push(result, actual, expected, message);
};


QUnit.extend(QUnit.assert, {
close: close,
notClose: notClose
});
17 changes: 14 additions & 3 deletions external/qunit-composite/qunit-composite.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/**
* QUnit Composite v1.0.4
* QUnit Composite v1.0.5-pre
*
* https://github.com/JamesMGreene/qunit-composite
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* https://jquery.org/license/
*/
(function( QUnit ) {
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
define( [ "qunit" ], factory );
} else {
factory( QUnit );
}
}(function( QUnit ) {
var iframe, hasBound,
modules = 1,
executingComposite = false;
Expand Down Expand Up @@ -60,6 +66,11 @@ function initIframe() {
return;
}

// Deal with QUnit being loaded asynchronously via AMD
if ( !iframeWin.QUnit && iframeWin.define && iframeWin.define.amd ) {
return iframeWin.require( [ "qunit" ], onIframeLoad );
}

iframeWin.QUnit.moduleStart(function( data ) {
// Capture module name for messages
moduleName = data.name;
Expand Down Expand Up @@ -181,4 +192,4 @@ QUnit.testDone(function( data ) {
current.getElementsByTagName( "a" )[ 0 ].href = src;
});

})( QUnit );
}));
Loading