summaryrefslogtreecommitdiff
path: root/src/main/webapp/jquery-ui-1.9pre/tests/unit/button
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-11-25 21:18:19 +0100
committerLeif Johansson <leifj@sunet.se>2011-11-25 21:18:19 +0100
commit3909e6d89e01e4cd8777377c63037896bb95aa2f (patch)
tree59679df287c2bee55087fb5afb8d42e7f93a44fb /src/main/webapp/jquery-ui-1.9pre/tests/unit/button
parente5f94e9be5017f627c1ccd8c6306c5cc2e200432 (diff)
new jq layout
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/button')
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/all.html30
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button.html71
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_core.js84
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_defaults.js14
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_events.js8
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_methods.js19
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_options.js93
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_tickets.js59
8 files changed, 378 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/all.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/all.html
new file mode 100644
index 0000000..fa9e224
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/all.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Button Test Suite</title>
+
+ <script src="../../../jquery-1.7.1.js"></script>
+
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <link rel="stylesheet" href="../subsuiteRunner.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../subsuiteRunner.js"></script>
+ <script src="../subsuite.js"></script>
+
+ <script>
+ testAllVersions( "button" );
+ </script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Button 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-fixture">
+
+</div>
+</body>
+</html>
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button.html
new file mode 100644
index 0000000..5ec7e31
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button.html
@@ -0,0 +1,71 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Button Test Suite</title>
+
+ <script src="../../jquery.js"></script>
+ <script src="../../resource_loader.js"></script>
+ <script>
+ loadResources({
+ css: [ "ui.core", "ui.button" ],
+ js: [
+ "ui/jquery.ui.core.js",
+ "ui/jquery.ui.widget.js",
+ "ui/jquery.ui.button.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 src="button_core.js"></script>
+ <script src="button_defaults.js"></script>
+ <script src="button_events.js"></script>
+ <script src="button_methods.js"></script>
+ <script src="button_options.js"></script>
+ <script src="button_tickets.js"></script>
+
+ <script src="../swarminject.js"></script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Button 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-fixture">
+
+<div><button id="button" class="foo">Label</button></div>
+
+<div id="radio0" style="margin-top: 2em;">
+ <input type="radio" id="radio01" name="radio" checked="checked"><label for="radio01">Choice 1</label>
+ <input type="radio" id="radio02" name="radio"><label for="radio02">Choice 2</label>
+ <input type="radio" id="radio03" name="radio"><label for="radio03">Choice 3</label>
+</div>
+<form>
+ <div id="radio1" style="margin-top: 2em;">
+ <input type="radio" id="radio11" name="radio"><label for="radio11">Choice 1</label>
+ <input type="radio" id="radio12" name="radio" checked="checked"><label for="radio12">Choice 2</label>
+ <input type="radio" id="radio13" name="radio"><label for="radio13">Choice 3</label>
+ </div>
+</form>
+<form>
+ <div id="radio2" style="margin-top: 2em;">
+ <input type="radio" id="radio21" name="radio"><label for="radio21">Choice 1</label>
+ <input type="radio" id="radio22" name="radio"><label for="radio22">Choice 2</label>
+ <input type="radio" id="radio23" name="radio" checked="checked"><label for="radio23">Choice 3</label>
+ </div>
+</form>
+
+<input type="checkbox" id="check"><label for="check">Toggle</label>
+
+<div><input id="submit" type="submit" value="Label"></div>
+
+</div>
+</body>
+</html>
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_core.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_core.js
new file mode 100644
index 0000000..692c403
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_core.js
@@ -0,0 +1,84 @@
+/*
+ * button_core.js
+ */
+
+
+(function($) {
+
+module("button: core");
+
+test("checkbox", function() {
+ var input = $("#check");
+ label = $("label[for=check]");
+ ok( input.is(":visible") );
+ ok( label.is(":not(.ui-button)") );
+ input.button();
+ ok( input.is(".ui-helper-hidden-accessible") );
+ ok( label.is(".ui-button") );
+});
+
+test("radios", function() {
+ var inputs = $("#radio0 input");
+ labels = $("#radio0 label");
+ ok( inputs.is(":visible") );
+ ok( labels.is(":not(.ui-button)") );
+ inputs.button();
+ ok( inputs.is(".ui-helper-hidden-accessible") );
+ ok( labels.is(".ui-button") );
+});
+
+function assert(noForm, form1, form2) {
+ ok( $("#radio0 .ui-button" + noForm).is(".ui-state-active") );
+ ok( $("#radio1 .ui-button" + form1).is(".ui-state-active") );
+ ok( $("#radio2 .ui-button" + form2).is(".ui-state-active") );
+}
+
+test("radio groups", function() {
+ $(":radio").button();
+ assert(":eq(0)", ":eq(1)", ":eq(2)");
+
+ // click outside of forms
+ $("#radio0 .ui-button:eq(1)").click();
+ assert(":eq(1)", ":eq(1)", ":eq(2)");
+
+ // click in first form
+ $("#radio1 .ui-button:eq(0)").click();
+ assert(":eq(1)", ":eq(0)", ":eq(2)");
+
+ // click in second form
+ $("#radio2 .ui-button:eq(0)").click();
+ assert(":eq(1)", ":eq(0)", ":eq(0)");
+});
+
+test("input type submit, don't create child elements", function() {
+ var input = $("#submit")
+ same( input.children().length, 0 );
+ input.button();
+ same( input.children().length, 0 );
+});
+
+test("buttonset", function() {
+ var set = $("#radio1").buttonset();
+ ok( set.is(".ui-buttonset") );
+ same( set.children(".ui-button").length, 3 );
+ same( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+ ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
+ ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
+ ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
+});
+
+test("buttonset (rtl)", function() {
+ var parent = $("#radio1").parent();
+ // Set to rtl
+ parent.attr("dir", "rtl");
+
+ var set = $("#radio1").buttonset();
+ ok( set.is(".ui-buttonset") );
+ same( set.children(".ui-button").length, 3 );
+ same( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+ ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
+ ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
+ ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_defaults.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_defaults.js
new file mode 100644
index 0000000..96c7e5b
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_defaults.js
@@ -0,0 +1,14 @@
+commonWidgetTests( "button", {
+ defaults: {
+ disabled: null,
+ icons: {
+ primary: null,
+ secondary: null
+ },
+ label: null,
+ text: true,
+
+ // callbacks
+ create: null
+ }
+});
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_events.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_events.js
new file mode 100644
index 0000000..a215402
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_events.js
@@ -0,0 +1,8 @@
+/*
+ * button_events.js
+ */
+(function($) {
+
+module("button: events");
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_methods.js
new file mode 100644
index 0000000..a83a73b
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_methods.js
@@ -0,0 +1,19 @@
+/*
+ * button_methods.js
+ */
+(function($) {
+
+
+module("button: methods");
+
+test("destroy", function() {
+ var beforeHtml = $("#button").parent().html();
+ var afterHtml = $("#button").button().button("destroy").parent().html();
+ // Opera 9 outputs role="" instead of removing the attribute like everyone else
+ if ($.browser.opera) {
+ afterHtml = afterHtml.replace(/ role=""/g, "");
+ }
+ equal( afterHtml, beforeHtml );
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_options.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_options.js
new file mode 100644
index 0000000..a3ab5ae
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_options.js
@@ -0,0 +1,93 @@
+/*
+ * button_options.js
+ */
+(function($) {
+
+module("button: options");
+
+test("disabled, explicit value", function() {
+ $("#radio01").button({ disabled: false });
+ same(false, $("#radio01").button("option", "disabled"),
+ "disabled option set to false");
+ same(false, $("#radio01").prop("disabled"), "element is disabled");
+
+ $("#radio02").button({ disabled: true });
+ same(true, $("#radio02").button("option", "disabled"),
+ "disabled option set to true");
+ same(true, $("#radio02").prop("disabled"), "element is not disabled");
+});
+
+test("disabled, null", function() {
+ $("#radio01").button({ disabled: null });
+ same(false, $("#radio01").button("option", "disabled"),
+ "disabled option set to false");
+ same(false, $("#radio01").prop("disabled"), "element is disabled");
+
+ $("#radio02").prop("disabled", true).button({ disabled: null });
+ same(true, $("#radio02").button("option", "disabled"),
+ "disabled option set to true");
+ same(true, $("#radio02").prop("disabled"), "element is not disabled");
+});
+
+test("text false without icon", function() {
+ $("#button").button({
+ text: false
+ });
+ ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") );
+
+ $("#button").button("destroy");
+});
+
+test("text false with icon", function() {
+ $("#button").button({
+ text: false,
+ icons: {
+ primary: "iconclass"
+ }
+ });
+ ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") );
+
+ $("#button").button("destroy");
+});
+
+test("label, default", function() {
+ $("#button").button();
+ same( $("#button").text(), "Label" );
+
+ $("#button").button("destroy");
+});
+
+test("label", function() {
+ $("#button").button({
+ label: "xxx"
+ });
+ same( $("#button").text(), "xxx" );
+
+ $("#button").button("destroy");
+});
+
+test("label default with input type submit", function() {
+ same( $("#submit").button().val(), "Label" );
+});
+
+test("label with input type submit", function() {
+ var label = $("#submit").button({
+ label: "xxx"
+ }).val();
+ same( label, "xxx" );
+});
+
+test("icons", function() {
+ $("#button").button({
+ text: false,
+ icons: {
+ primary: "iconclass",
+ secondary: "iconclass2"
+ }
+ });
+ ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") );
+
+ $("#button").button("destroy");
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_tickets.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_tickets.js
new file mode 100644
index 0000000..624d167
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/button/button_tickets.js
@@ -0,0 +1,59 @@
+/*
+ * button_tickets.js
+ */
+(function( $ ) {
+
+module( "button: tickets" );
+
+test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
+ $( "#radio01" ).next().andSelf().hide();
+ var set = $( "#radio0" ).buttonset({ items: ":radio:visible" });
+ ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
+ ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
+});
+
+test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
+ $( "#radio0" ).hide();
+ var set = $( "#radio0" ).buttonset();
+ ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
+ ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
+ ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
+});
+
+test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
+ var check = $( "#check" ).button(),
+ label = $( "label[for='check']" );
+ ok( !label.is( ".ui-state-focus" ) );
+ check.focus();
+ ok( label.is( ".ui-state-focus" ) );
+});
+
+test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
+ var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
+ group.find( "input:checkbox" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ) );
+
+ group = $( "<input type='checkbox' id='t7092b'><label for='t7092b'></label>" );
+ group.filter( "input:checkbox" ).button();
+ ok( group.filter( "label" ).is( ".ui-button" ) );
+
+ group = $( "<span><input type='checkbox' id='t7092c'></span><label for='t7092c'></label>" );
+ group.find( "input:checkbox" ).button();
+ ok( group.filter( "label" ).is( ".ui-button" ) );
+
+ group = $( "<span><input type='checkbox' id='t7092d'></span><span><label for='t7092d'></label></span>" );
+ group.find( "input:checkbox" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ) );
+
+ group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
+ group.filter( "input:checkbox" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ) );
+});
+
+test( "#7534 - Button label selector works for ids with \":\"", function() {
+ var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
+ group.find( "input" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
+});
+
+})( jQuery );