source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/tests/unit/button/button_core.js@ 24245

Last change on this file since 24245 was 24245, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1/*
2 * button_core.js
3 */
4
5
6(function($) {
7
8module("button: core");
9
10test("checkbox", function() {
11 var input = $("#check");
12 label = $("label[for=check]");
13 ok( input.is(":visible") );
14 ok( label.is(":not(.ui-button)") );
15 input.button();
16 ok( input.is(":hidden") );
17 ok( label.is(".ui-button") );
18});
19
20test("radios", function() {
21 var inputs = $("#radio0 input");
22 labels = $("#radio0 label");
23 ok( inputs.is(":visible") );
24 ok( labels.is(":not(.ui-button)") );
25 inputs.button();
26 ok( inputs.is(":hidden") );
27 ok( labels.is(".ui-button") );
28});
29
30function assert(noForm, form1, form2) {
31 ok( $("#radio0 .ui-button" + noForm).is(".ui-state-active") );
32 ok( $("#radio1 .ui-button" + form1).is(".ui-state-active") );
33 ok( $("#radio2 .ui-button" + form2).is(".ui-state-active") );
34}
35
36test("radio groups", function() {
37 $(":radio").button();
38 assert(":eq(0)", ":eq(1)", ":eq(2)");
39
40 // click outside of forms
41 $("#radio0 .ui-button:eq(1)").click();
42 assert(":eq(1)", ":eq(1)", ":eq(2)");
43
44 // click in first form
45 $("#radio1 .ui-button:eq(0)").click();
46 assert(":eq(1)", ":eq(0)", ":eq(2)");
47
48 // click in second form
49 $("#radio2 .ui-button:eq(0)").click();
50 assert(":eq(1)", ":eq(0)", ":eq(0)");
51});
52
53test("input type submit, don't create child elements", function() {
54 var input = $("#submit")
55 same( input.children().length, 0 );
56 input.button();
57 same( input.children().length, 0 );
58});
59
60test("buttonset", function() {
61 var set = $("#radio1").buttonset();
62 ok( set.is(".ui-button-set") );
63 same( set.children(".ui-button").length, 3 );
64 same( set.children("input:radio:hidden").length, 3 );
65 ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
66 ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
67 ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
68});
69
70})(jQuery);
Note: See TracBrowser for help on using the repository browser.