Tests: Moved loadResources to TestHelpers.

This commit is contained in:
Scott González 2012-04-23 10:43:01 -04:00
parent 7a5a77da50
commit b042f8ebd6
25 changed files with 145 additions and 209 deletions

View File

@ -1,40 +0,0 @@
(function( $ ) {
var parts = document.location.search.slice( 1 ).split( "&" ),
length = parts.length,
i = 0,
current,
min;
for ( ; i < length; i++ ) {
current = parts[ i ].split( "=" );
if ( current[ 0 ] === "min" ) {
min = current[ 1 ];
break;
}
}
function includeStyle( url ) {
document.write( "<link rel='stylesheet' href='../../../" + url + "'>" );
}
function includeScript( url ) {
document.write( "<script src='../../../" + url + "'></script>" );
}
window.loadResources = min ?
function() {
// TODO: proper include with theme images
includeStyle( "dist/jquery-ui.min.css" );
includeScript( "dist/jquery-ui.min.js" );
} :
function( resources ) {
$.each( resources.css || [], function( i, resource ) {
includeStyle( "themes/base/jquery." + resource + ".css" );
});
$.each( resources.js || [], function( i, resource ) {
includeScript( resource );
});
};
})( jQuery );

View File

@ -8,9 +8,12 @@
<script>
$.uiBackCompat = false;
</script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.accordion" ],
js: [
"ui/jquery.ui.core.js",
@ -20,11 +23,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="accordion_test_helpers.js"></script>
<script src="accordion_common.js"></script>
<script src="accordion_core.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Accordion Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.accordion" ],
js: [
"ui/jquery.ui.core.js",
@ -17,11 +20,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="accordion_test_helpers.js"></script>
<script src="accordion_common_deprecated.js"></script>
<script src="accordion_core.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Autocomplete Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.menu", "ui.autocomplete" ],
js: [
"ui/jquery.ui.core.js",
@ -19,11 +22,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="autocomplete_common.js"></script>
<script src="autocomplete_core.js"></script>
<script src="autocomplete_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Button Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.button" ],
js: [
"ui/jquery.ui.core.js",
@ -17,11 +20,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="button_common.js"></script>
<script src="button_core.js"></script>
<script src="button_events.js"></script>

View File

@ -5,17 +5,15 @@
<title>jQuery UI Core Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<script>
loadResources({
js: [ "ui/jquery.ui.core.js" ]
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
TestHelpers.loadResources({
js: [ "ui/jquery.ui.core.js" ]
});
</script>
<script src="core.js"></script>
<script src="selector.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Datepicker Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.datepicker" ],
js: [
"ui/jquery.ui.core.js",
@ -19,11 +22,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="datepicker_core.js"></script>
<script src="datepicker_defaults.js"></script>
<script src="datepicker_events.js"></script>

View File

@ -6,9 +6,12 @@
<script src="../../jquery.js"></script>
<script src="../../../external/jquery.bgiframe-2.1.2.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.dialog" ],
js: [
"ui/jquery.ui.core.js",
@ -22,11 +25,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="dialog_common.js"></script>
<script src="dialog_core.js"></script>
<script src="dialog_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Draggable Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core" ],
js: [
"ui/jquery.ui.core.js",
@ -18,11 +21,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="draggable_common.js"></script>
<script src="draggable_core.js"></script>
<script src="draggable_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Droppable Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core" ],
js: [
"ui/jquery.ui.core.js",
@ -19,11 +22,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="droppable_common.js"></script>
<script src="droppable_core.js"></script>
<script src="droppable_events.js"></script>

View File

@ -8,9 +8,12 @@
<script>
$.uiBackCompat = false;
</script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
js: [
"ui/jquery.effects.core.js",
"ui/jquery.effects.blind.js",
@ -30,10 +33,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="effects_core.js"></script>
<script src="effects_scale.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Menu Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.menu" ],
js: [
"ui/jquery.ui.core.js",
@ -17,11 +20,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="menu_test_helpers.js"></script>
<script src="menu_common.js"></script>
<script src="menu_core.js"></script>

View File

@ -8,17 +8,15 @@
<script>
$.uiBackCompat = false;
</script>
<script src="../../resource_loader.js"></script>
<script>
loadResources({
js: [ "ui/jquery.ui.position.js" ]
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
TestHelpers.loadResources({
js: [ "ui/jquery.ui.position.js" ]
});
</script>
<script src="position_core.js"></script>
<script src="position_core_within.js"></script>

View File

@ -5,17 +5,15 @@
<title>jQuery UI Position Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<script>
loadResources({
js: [ "ui/jquery.ui.position.js" ]
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
TestHelpers.loadResources({
js: [ "ui/jquery.ui.position.js" ]
});
</script>
<script src="position_core.js"></script>
<script src="position_deprecated.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Progressbar Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.progressbar" ],
js: [
"ui/jquery.ui.core.js",
@ -17,11 +20,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="progressbar_common.js"></script>
<script src="progressbar_core.js"></script>
<script src="progressbar_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Resizable Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.resizable" ],
js: [
"ui/jquery.ui.core.js",
@ -18,11 +21,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="resizable_common.js"></script>
<script src="resizable_core.js"></script>
<script src="resizable_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Selectable Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.selectable" ],
js: [
"ui/jquery.ui.core.js",
@ -18,11 +21,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="selectable_common.js"></script>
<script src="selectable_core.js"></script>
<script src="selectable_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Slider Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.slider" ],
js: [
"ui/jquery.ui.core.js",
@ -18,11 +21,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="slider_common.js"></script>
<script src="slider_core.js"></script>
<script src="slider_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Sortable Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.sortable" ],
js: [
"ui/jquery.ui.core.js",
@ -18,11 +21,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="sortable_common.js"></script>
<script src="sortable_core.js"></script>
<script src="sortable_events.js"></script>

View File

@ -8,9 +8,12 @@
<script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
<script src="../../../external/globalize.js"></script>
<script src="../../../external/globalize.culture.ja-JP.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.button", "ui.spinner" ],
js: [
"ui/jquery.ui.core.js",
@ -21,11 +24,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="spinner_test_helpers.js"></script>
<script src="spinner_common.js"></script>
<script src="spinner_core.js"></script>

View File

@ -8,9 +8,12 @@
<script>
$.uiBackCompat = false;
</script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.tabs" ],
js: [
"ui/jquery.ui.core.js",
@ -20,11 +23,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="tabs_test_helpers.js"></script>
<script src="tabs_common.js"></script>
<script src="tabs_core.js"></script>

View File

@ -6,9 +6,12 @@
<script src="../../jquery.js"></script>
<script src="../../../external/jquery.cookie.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.tabs" ],
js: [
"ui/jquery.ui.core.js",
@ -18,11 +21,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="tabs_test_helpers.js"></script>
<script src="tabs_common_deprecated.js"></script>
<script src="tabs_core.js"></script>

View File

@ -2,12 +2,35 @@
window.TestHelpers = {};
function includeStyle( url ) {
document.write( "<link rel='stylesheet' href='../../../" + url + "'>" );
}
function includeScript( url ) {
document.write( "<script src='../../../" + url + "'></script>" );
}
TestHelpers.loadResources = QUnit.urlParams.min ?
function() {
// TODO: proper include with theme images
includeStyle( "dist/jquery-ui.min.css" );
includeScript( "dist/jquery-ui.min.js" );
} :
function( resources ) {
$.each( resources.css || [], function( i, resource ) {
includeStyle( "themes/base/jquery." + resource + ".css" );
});
$.each( resources.js || [], function( i, resource ) {
includeScript( resource );
});
};
function testJshint( widget ) {
if ( QUnit.urlParams.nojshint ) {
return;
}
document.write( "<script src='../../../external/jshint.js'></script>" );
includeScript( "external/jshint.js" );
asyncTest( "JSHint", function() {
expect( 1 );
@ -58,17 +81,15 @@ function testWidgetDefaults( widget, defaults ) {
});
}
var privateMethods = [
function testWidgetOverrides( widget ) {
if ( $.uiBackCompat === false ) {
test( "$.widget overrides", function() {
$.each([
"_createWidget",
"destroy",
"option",
"_trigger"
];
function testWidgetOverrides( widget ) {
if ( $.uiBackCompat === false ) {
test( "$.widget overrides", function() {
$.each( privateMethods, function( i, method ) {
], function( i, method ) {
strictEqual( $.ui[ widget ].prototype[ method ],
$.Widget.prototype[ method ], "should not override " + method );
});

View File

@ -5,9 +5,12 @@
<title>jQuery UI Tooltip Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core", "ui.tooltip" ],
js: [
"ui/jquery.ui.core.js",
@ -18,11 +21,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="tooltip_common.js"></script>
<script src="tooltip_core.js"></script>
<script src="tooltip_events.js"></script>

View File

@ -5,9 +5,12 @@
<title>jQuery UI Widget Test Suite</title>
<script src="../../jquery.js"></script>
<script src="../../resource_loader.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
loadResources({
TestHelpers.loadResources({
css: [ "ui.core" ],
js: [
"ui/jquery.ui.widget.js"
@ -15,11 +18,6 @@
});
</script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="widget_core.js"></script>
<script src="widget_extend.js"></script>
<script src="widget_animation.js"></script>