diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-01-07 03:19:50 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-01-07 03:19:50 +0000 |
commit | 90fb45dffafc2e891b1ebca948ad33e6b94de112 (patch) | |
tree | 6bd09ea116ef2cdd86ec0fa70bf740617f67d441 /tests/unit/button/button_core.js | |
parent | 975b02a82cdff29fd8469bfe4324472c2ae3f954 (diff) | |
download | jquery-ui-90fb45dffafc2e891b1ebca948ad33e6b94de112.tar.gz jquery-ui-90fb45dffafc2e891b1ebca948ad33e6b94de112.zip |
Merged in /branches/dev r3251:3620 (excluding autocomplete, modal, tooltip, menu; including menu static tests).
Diffstat (limited to 'tests/unit/button/button_core.js')
-rw-r--r-- | tests/unit/button/button_core.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js new file mode 100644 index 000000000..12016627f --- /dev/null +++ b/tests/unit/button/button_core.js @@ -0,0 +1,70 @@ +/*
+ * button_core.js
+ */
+
+
+(function($) {
+
+module("button: core");
+
+test("checkbox", function() {
+ var input = $("#check");
+ label = $("label[for=check]");
+ ok( input.is(":visble") );
+ ok( label.is(":not(.ui-button)") );
+ input.button();
+ ok( input.is(":hidden") );
+ ok( label.is(".ui-button") );
+});
+
+test("radios", function() {
+ var inputs = $("#radio0 input");
+ labels = $("#radio0 label");
+ ok( inputs.is(":visble") );
+ ok( labels.is(":not(.ui-button)") );
+ inputs.button();
+ ok( inputs.is(":hidden") );
+ 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-button-set") );
+ same( set.children(".ui-button").length, 3 );
+ same( set.children("input:radio:hidden").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)") );
+});
+
+})(jQuery);
|