aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/dialog/dialog_tickets.js2
-rw-r--r--tests/unit/menu/menu.html6
-rw-r--r--tests/unit/menu/menu_common.js3
-rw-r--r--tests/unit/menu/menu_methods.js24
-rw-r--r--tests/unit/menu/menu_options.js51
-rw-r--r--tests/unit/spinner/spinner.html2
-rw-r--r--tests/unit/spinner/spinner_common.js4
-rw-r--r--tests/unit/spinner/spinner_options.js19
-rw-r--r--tests/unit/tabs/tabs_core.js18
-rw-r--r--tests/unit/tabs/tabs_options.js50
-rw-r--r--tests/unit/testsuite.js14
-rw-r--r--tests/unit/widget/widget_core.js2
12 files changed, 178 insertions, 17 deletions
diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js
index 201ea3a87..5c3277c2f 100644
--- a/tests/unit/dialog/dialog_tickets.js
+++ b/tests/unit/dialog/dialog_tickets.js
@@ -10,7 +10,7 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
inputs = el.find( "input" ),
- widget = el.dialog( "widget" );
+ widget = el.dialog( "widget" )[ 0 ];
function checkTab() {
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index c58b9fc65..ed376232e 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -44,11 +44,7 @@
</head>
<body>
-<h1 id="qunit-header">jQuery UI Menu Test Suite</h1>
-<h2 id="qunit-banner"></h2>
-<div id="qunit-testrunner-toolbar"></div>
-<h2 id="qunit-userAgent"></h2>
-<ol id="qunit-tests"></ol>
+<div id="qunit">jQuery UI Menu Test Suite</div>
<div id="qunit-fixture">
<ul class="foo" id="menu1">
diff --git a/tests/unit/menu/menu_common.js b/tests/unit/menu/menu_common.js
index 07295f1af..4a89a947a 100644
--- a/tests/unit/menu/menu_common.js
+++ b/tests/unit/menu/menu_common.js
@@ -1,6 +1,9 @@
TestHelpers.commonWidgetTests( "menu", {
defaults: {
disabled: false,
+ icons: {
+ submenu: "ui-icon-carat-1-e"
+ },
menus: "ul",
position: {
my: "left top",
diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js
index 0835f61ec..510ddb1d7 100644
--- a/tests/unit/menu/menu_methods.js
+++ b/tests/unit/menu/menu_methods.js
@@ -44,6 +44,30 @@ test( "refresh", function() {
equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
});
+// TODO: test focus method
+
+// TODO: test blur method
+
+// TODO: test collapseAll method
+
+// TODO: test collapse method
+
+// TODO: test expand method
+
+// TODO: test next method
+
+// TODO: test prev method
+
+// TODO: test isFirstItem method
+
+// TODO: test isLastItem method
+
+// TODO: test nextPage method
+
+// TODO: test prevPage method
+
+// TODO: test select method
+
test( "destroy", function() {
expect( 4 );
domEqual( "#menu1", function() {
diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js
index 27c2fabb3..a8b029201 100644
--- a/tests/unit/menu/menu_options.js
+++ b/tests/unit/menu/menu_options.js
@@ -18,7 +18,7 @@ test( "{ disabled: true }", function() {
log();
}
});
- ok( element.is( ".ui-state-disabled" ), "Missing ui-state-disabled class" );
+ ok( element.hasClass( "ui-state-disabled" ), "Missing ui-state-disabled class" );
log( "click", true );
click( element, "1" );
log( "afterclick" );
@@ -33,14 +33,34 @@ test( "{ disabled: false }", function() {
log();
}
});
- ok( element.not( ".ui-state-disabled" ), "Has ui-state-disabled class" );
+ ok( !element.hasClass( "ui-state-disabled" ), "Has ui-state-disabled class" );
log( "click", true );
click( element, "1" );
log( "afterclick" );
equal( logOutput(), "click,1,afterclick", "Click order not valid." );
});
-test( "{ role: 'menu' } ", function () {
+test( "{ icons: default }", function() {
+ expect( 1 );
+ var element = $( "#menu2" ).menu();
+ equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-carat-1-e" );
+});
+
+test( "{ icons: { submenu: 'custom' } }", function() {
+ expect( 1 );
+ var element = $( "#menu2" ).menu({
+ icons: {
+ submenu: "custom-class"
+ }
+ });
+ equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon custom-class" );
+});
+
+// TODO: test menus option
+
+// TODO: test position option
+
+test( "{ role: 'menu' } ", function() {
var element = $( "#menu1" ).menu(),
items = element.find( "li" );
expect( 2 + 5 * items.length );
@@ -55,16 +75,37 @@ test( "{ role: 'menu' } ", function () {
});
});
-test( "{ role: 'listbox' } ", function () {
+test( "{ role: 'listbox' } ", function() {
var element = $( "#menu1" ).menu({
role: "listbox"
}),
items = element.find( "li" );
- expect( 2 + items.length );
+ expect( 2 + 5 * items.length );
equal( element.attr( "role" ), "listbox" );
ok( items.length > 0, "number of menu items" );
items.each(function( item ) {
+ ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
+ equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
equal( $( "a", this ).attr( "role" ), "option", "menu item ("+ item + ") role" );
+ ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
+ equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
+ });
+});
+
+test( "{ role: null }", function() {
+ var element = $( "#menu1" ).menu({
+ role: null
+ }),
+ items = element.find( "li" );
+ expect( 2 + 5 * items.length );
+ strictEqual( element.attr( "role" ), undefined );
+ ok( items.length > 0, "number of menu items" );
+ items.each(function( item ) {
+ ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
+ equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
+ equal( $( "a", this ).attr( "role" ), undefined, "menu item ("+ item + ") role" );
+ ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
+ equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
});
});
diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html
index b7f4a532a..1d09bbc38 100644
--- a/tests/unit/spinner/spinner.html
+++ b/tests/unit/spinner/spinner.html
@@ -5,7 +5,7 @@
<title>jQuery UI Spinner Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
+ <script src="../../../external/jquery.mousewheel.js"></script>
<script src="../../../external/globalize.js"></script>
<script src="../../../external/globalize.culture.ja-JP.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
diff --git a/tests/unit/spinner/spinner_common.js b/tests/unit/spinner/spinner_common.js
index 4f05b1e63..b494e3ca3 100644
--- a/tests/unit/spinner/spinner_common.js
+++ b/tests/unit/spinner/spinner_common.js
@@ -2,6 +2,10 @@ TestHelpers.commonWidgetTests( "spinner", {
defaults: {
culture: null,
disabled: false,
+ icons: {
+ down: "ui-icon-triangle-1-s",
+ up: "ui-icon-triangle-1-n"
+ },
incremental: true,
max: null,
min: null,
diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js
index e21852630..1f6646a33 100644
--- a/tests/unit/spinner/spinner_options.js
+++ b/tests/unit/spinner/spinner_options.js
@@ -6,6 +6,25 @@ module( "spinner: options" );
// culture is tested after numberFormat, since it depends on numberFormat
+test( "icons: default ", function() {
+ expect( 2 );
+ var element = $( "#spin" ).val( 0 ).spinner().spinner( "widget" );
+ equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
+ equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
+});
+
+test( "icons: custom ", function() {
+ expect( 2 );
+ var element = $( "#spin" ).val( 0 ).spinner({
+ icons: {
+ down: "custom-down",
+ up: "custom-up"
+ }
+ }).spinner( "widget" );
+ equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon custom-up" );
+ equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon custom-down" );
+});
+
test( "incremental, false", function() {
expect( 100 );
diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js
index fd9cc7d63..f1a2d72c1 100644
--- a/tests/unit/tabs/tabs_core.js
+++ b/tests/unit/tabs/tabs_core.js
@@ -118,8 +118,24 @@ test( "accessibility", function() {
equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
+});
- // TODO: aria-live and aria-busy tests for ajax tabs
+asyncTest( "accessibility - ajax", function() {
+ expect( 4 );
+ var element = $( "#tabs2" ).tabs(),
+ tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
+ panel = $( "#custom-id" );
+
+ equal( panel.attr( "aria-live" ), "polite", "remote panel has aria-live" );
+ equal( panel.attr( "aria-busy" ), null, "does not have aria-busy on init" );
+ element.tabs( "option", "active", 3 );
+ equal( panel.attr( "aria-busy" ), "true", "panel has aria-busy during load" );
+ element.one( "tabsload", function() {
+ setTimeout(function() {
+ equal( panel.attr( "aria-busy" ), null, "panel does not have aria-busy after load" );
+ start();
+ }, 1 );
+ });
});
asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", function() {
diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js
index eed5b99d8..5a90ff895 100644
--- a/tests/unit/tabs/tabs_options.js
+++ b/tests/unit/tabs/tabs_options.js
@@ -280,6 +280,54 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
equalHeight( element, 335 );
});
-// TODO: add animation tests
+test( "hide and show: false", function() {
+ expect( 3 );
+ var element = $( "#tabs1" ).tabs({
+ show: false,
+ hide: false
+ }),
+ widget = element.data( "tabs" ),
+ panels = element.find( ".ui-tabs-panel" );
+ widget._show = function() {
+ ok( false, "_show() called" );
+ };
+ widget._hide = function() {
+ ok( false, "_hide() called" );
+ };
+
+ ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ element.tabs( "option", "active", 1 );
+ ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+});
+
+asyncTest( "hide and show - animation", function() {
+ expect( 5 );
+ var element = $( "#tabs1" ).tabs({
+ show: "drop",
+ hide: 2000
+ }),
+ widget = element.data( "tabs" ),
+ panels = element.find( ".ui-tabs-panel" );
+ widget._show = function( element, options, callback ) {
+ strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
+ equal( options, "drop", "correct options in _show()" );
+ setTimeout(function() {
+ callback();
+ }, 1 );
+ };
+ widget._hide = function( element, options, callback ) {
+ strictEqual( element[ 0 ], panels[ 0 ], "correct element in _hide()" );
+ equal( options, 2000, "correct options in _hide()" );
+ setTimeout(function() {
+ callback();
+ start();
+ }, 1 );
+ };
+
+ ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ element.tabs( "option", "active", 1 );
+});
+
}( jQuery ) );
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index 99694a83e..26f46138a 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -12,7 +12,12 @@ function includeScript( url ) {
QUnit.config.requireExpects = true;
-QUnit.config.urlConfig.push( "min" );
+QUnit.config.urlConfig.push({
+ id: "min",
+ label: "Minified source",
+ tooltip: "Load minified source files instead of the regular unminified ones."
+});
+
TestHelpers.loadResources = QUnit.urlParams.min ?
function() {
// TODO: proper include with theme images
@@ -28,7 +33,12 @@ TestHelpers.loadResources = QUnit.urlParams.min ?
});
};
-QUnit.config.urlConfig.push( "nojshint" );
+QUnit.config.urlConfig.push({
+ id: "nojshint",
+ label: "Skip JSHint",
+ tooltip: "Skip running JSHint, e.g. within TestSwarm, where Jenkins runs it already"
+});
+
var jshintLoaded = false;
TestHelpers.testJshint = function( module ) {
if ( QUnit.urlParams.nojshint ) {
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 0296b9e4f..5efd91268 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -83,7 +83,7 @@ test( "custom selector expression", function() {
var elem = $( "<div>" ).appendTo( "#qunit-fixture" );
$.widget( "ui.testWidget", {} );
elem.testWidget();
- deepEqual( $( ":ui-testWidget" )[0], elem[0] );
+ deepEqual( $( ":ui-testwidget" )[0], elem[0] );
elem.testWidget( "destroy" );
});